MCPcopy Create free account
hub / github.com/hashintel/hash / debug_render

Function debug_render

libs/error-stack/src/fmt/mod.rs:948–1020  ·  view source on GitHub ↗
(head: Lines, contexts: VecDeque<Lines>, sources: Vec<Lines>)

Source from the content-addressed store, hash-verified

946}
947
948fn debug_render(head: Lines, contexts: VecDeque<Lines>, sources: Vec<Lines>) -> Lines {
949 let len = sources.len();
950 let sources = sources
951 .into_iter()
952 .enumerate()
953 .map(|(idx, lines)| {
954 let position = match idx {
955 // this is first to make sure that 0 is caught as `Last` instead of `First`
956 pos if pos + 1 == len => Position::Final,
957 0 => Position::First,
958 _ => Position::Inner,
959 };
960
961 lines
962 .into_iter()
963 .enumerate()
964 .map(|(idx, line)| {
965 if idx == 0 {
966 line.push(Instruction::Group { position })
967 } else {
968 line.push(
969 Indent::group()
970 .visible(!matches!(position, Position::Final))
971 .into(),
972 )
973 }
974 })
975 .collect::<Lines>()
976 .before(
977 // add a buffer line for readability
978 Line::new().push(Indent::new(idx != 0).spacing(None).into()),
979 )
980 })
981 .collect::<Vec<_>>();
982
983 let tail = !sources.is_empty();
984 let len = contexts.len();
985
986 // insert the arrows and buffer indentation
987 let contexts = contexts.into_iter().enumerate().flat_map(|(idx, lines)| {
988 let position = match idx {
989 pos if pos + 1 == len && !tail => Position::Final,
990 0 => Position::First,
991 _ => Position::Inner,
992 };
993
994 let mut lines = lines
995 .into_iter()
996 .enumerate()
997 .map(|(idx, line)| {
998 if idx == 0 {
999 line.push(Instruction::Context { position })
1000 } else {
1001 line.push(
1002 Indent::no_group()
1003 .visible(!matches!(position, Position::Final))
1004 .into(),
1005 )

Callers

nothing calls this directly

Calls 10

beforeMethod · 0.80
visibleMethod · 0.80
spacingMethod · 0.80
collectMethod · 0.80
pushMethod · 0.65
lenMethod · 0.45
mapMethod · 0.45
into_iterMethod · 0.45
is_emptyMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected