pub struct InspectListClosure<'a, T, F>(pub &'a [T], pub F)
where
F: Fn(&Node, &str, &T);
Expand description
Wrapper around a list [T]
and a closure function F
that determines how to map
and log each value of T
in inspect_log!
or inspect_insert!
macro.
Example:
let list = ["foo", "bar", "baz"]
let list_mapped = InspectListClosure(&list, |node_writer, key, item| {
let mapped_item = format!("super{}", item);
inspect_insert!(node_writer, var key: mapped_item);
});
inspect_insert!(node_writer, some_list: list_mapped);
The above code snippet would create the following child under node_writer:
some_list:
0: "superfoo"
1: "superbar"
2: "superbaz"
Tuple Fields§
§0: &'a [T]
§1: F
Trait Implementations§
Source§impl<'a, T, F> WriteInspect for InspectListClosure<'a, T, F>
impl<'a, T, F> WriteInspect for InspectListClosure<'a, T, F>
Source§fn write_inspect(&self, writer: &Node, key: impl Into<StringReference>)
fn write_inspect(&self, writer: &Node, key: impl Into<StringReference>)
Write a single value (property or child node) to |node| with the specified |key|.
If multiple properties need to be written, consider creating a single child
node with those properties.
Auto Trait Implementations§
impl<'a, T, F> Freeze for InspectListClosure<'a, T, F>where
F: Freeze,
impl<'a, T, F> RefUnwindSafe for InspectListClosure<'a, T, F>where
F: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, F> Send for InspectListClosure<'a, T, F>
impl<'a, T, F> Sync for InspectListClosure<'a, T, F>
impl<'a, T, F> Unpin for InspectListClosure<'a, T, F>where
F: Unpin,
impl<'a, T, F> UnwindSafe for InspectListClosure<'a, T, F>where
F: UnwindSafe,
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more