ItemSetMethods

Trait ItemSetMethods 

Source
pub trait ItemSetMethods: Copy + Sized {
    type Each: Sized;
    type Field: Sized;

    // Required methods
    fn accumulate(
        self,
        acc: &mut Option<Self::Field>,
        one: Self::Each,
    ) -> Result<(), EP>;
    fn finish(
        self,
        acc: Option<Self::Field>,
        item_keyword: &'static str,
    ) -> Result<Self::Field, EP>;

    // Provided methods
    fn is_intro_item_keyword(self, kw: KeywordRef<'_>) -> bool
       where Self::Each: NetdocParseable { ... }
    fn finish_subdoc(self, acc: Option<Self::Field>) -> Result<Self::Field, EP>
       where Self::Each: NetdocParseable { ... }
}
Available on crate feature parse2 only.
Expand description

Methods for handling some multiplicity of Items

For use by macros.

During parsing, we accumulate into a value of type Option<Self::Field>. The semantics of this are item-set-implementation-dependent; using a type which is generic over the field type in a simple way allows the partially-parsed accumulation state for a whole netdoc to have a concrete type.

See ItemSetSelector and the module-level docs.

Required Associated Types§

Source

type Each: Sized

The value for each Item.

Source

type Field: Sized

The output type: the type of the field in the netdoc struct.

Required Methods§

Source

fn accumulate( self, acc: &mut Option<Self::Field>, one: Self::Each, ) -> Result<(), EP>

Accumulate one value into the accumulator.

Source

fn finish( self, acc: Option<Self::Field>, item_keyword: &'static str, ) -> Result<Self::Field, EP>

Resolve the accumulator into the output.

Provided Methods§

Source

fn is_intro_item_keyword(self, kw: KeywordRef<'_>) -> bool
where Self::Each: NetdocParseable,

If the contained type is a sub-document, call its is_intro_item_keyword.

Source

fn finish_subdoc(self, acc: Option<Self::Field>) -> Result<Self::Field, EP>
where Self::Each: NetdocParseable,

finish for if the contained type is a wsub-document

Obtain the sub-document’s intro keyword from its doctype_for_error.

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§