Skip to main content

ListVisitor

Trait ListVisitor 

Source
pub trait ListVisitor: Sized + Sealed {
    type Result;

    // Required methods
    fn visit_item<T: Display>(&mut self, item: T) -> ControlFlow<Self::Result>;
    fn finish(self) -> Self::Result;

    // Provided method
    fn visit_items_and_finish<T, I>(self, items: I) -> Self::Result
       where T: Display,
             I: IntoIterator<Item = T> { ... }
}
Expand description

List visitor.

See the module documentation for usage.

Required Associated Types§

Source

type Result

Result of the visit.

Required Methods§

Source

fn visit_item<T: Display>(&mut self, item: T) -> ControlFlow<Self::Result>

Visits an item.

If this returned ControlFlow::Break(v), Context::visit should also return this v.

To feed multiple items at once, do items.into_iter().try_for_each(|item| self.visit_item(item)) for example.

Source

fn finish(self) -> Self::Result

Finishes visiting the list.

Provided Methods§

Source

fn visit_items_and_finish<T, I>(self, items: I) -> Self::Result
where T: Display, I: IntoIterator<Item = T>,

Visits items and finish.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§