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

Function iter_mut

libs/error-stack/tests/test_iter.rs:93–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

91
92#[test]
93fn iter_mut() {
94 let mut report = build();
95
96 let mut chars = Vec::new();
97 let flow = report.frames_mut(|frame| {
98 if let Some(ch) = frame.downcast_mut::<Char>() {
99 chars.push(ch.0);
100 ch.0 = ch.0.to_ascii_lowercase();
101 }
102 ControlFlow::Continue(())
103 });
104 assert!(flow.is_continue());
105 assert_eq!(chars, ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']);
106
107 assert_eq!(
108 report
109 .frames()
110 .filter_map(|frame| frame.downcast_ref::<Char>().map(|ch| ch.0))
111 .collect::<Vec<_>>(),
112 ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
113 );
114}
115
116#[test]
117fn iter_mut_break() {

Callers

nothing calls this directly

Calls 3

frames_mutMethod · 0.80
buildFunction · 0.70
pushMethod · 0.65

Tested by

no test coverage detected