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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§