iri_string::template::context

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.

Object Safety§

This trait is not object safe.

Implementors§