iri_string::template::context

Trait AssocVisitor

source
pub trait AssocVisitor: Sized + Sealed {
    type Result;

    // Required methods
    fn visit_entry<K: Display, V: Display>(
        &mut self,
        key: K,
        value: V,
    ) -> ControlFlow<Self::Result>;
    fn finish(self) -> Self::Result;

    // Provided method
    fn visit_entries_and_finish<K, V, I>(self, entries: I) -> Self::Result
       where K: Display,
             V: Display,
             I: IntoIterator<Item = (K, V)> { ... }
}
Expand description

Associative array visitor.

See the module documentation for usage.

Required Associated Types§

source

type Result

Result of the visit.

Required Methods§

source

fn visit_entry<K: Display, V: Display>( &mut self, key: K, value: V, ) -> ControlFlow<Self::Result>

Visits an entry.

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

To feed multiple items at once, do entries.into_iter().try_for_each(|(key, value)| self.visit_entry(key, value)) for example.

source

fn finish(self) -> Self::Result

Finishes visiting the associative array.

Provided Methods§

source

fn visit_entries_and_finish<K, V, I>(self, entries: I) -> Self::Result
where K: Display, V: Display, I: IntoIterator<Item = (K, V)>,

Visits entries and finish.

Object Safety§

This trait is not object safe.

Implementors§