ItemSetMethods

Trait ItemSetMethods 

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

    // Required methods
    fn can_accumulate(self, acc: &Option<Self::Field>) -> Result<(), EP>;
    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 { ... }
    fn check_item_value_parseable(self)
       where Self::Each: ItemValueParseable { ... }
    fn check_signature_item_parseable(self)
       where Self::Each: SignatureItemParseable { ... }
    fn check_subdoc_parseable(self)
       where Self::Each: NetdocParseable { ... }
    fn check_item_argument_parseable(self)
       where Self::Each: ItemArgumentParseable { ... }
}
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 can_accumulate(self, acc: &Option<Self::Field>) -> Result<(), EP>

Can we accumulate another item ?

Can be used to help predict whether accumulate will throw.

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.

Source

fn check_item_value_parseable(self)
where Self::Each: ItemValueParseable,

Check that the element type is an Item

For providing better error messages when struct fields don’t implement the right trait. See derive.rs, and search for this method name.

Source

fn check_signature_item_parseable(self)

Check that the element type is a Signature

Source

fn check_subdoc_parseable(self)
where Self::Each: NetdocParseable,

Check that the element type is a sub-document

Source

fn check_item_argument_parseable(self)

Check that the element type is an argument

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§