Module multiplicity

Module multiplicity 

Source
Available on crate feature parse2 only.
Expand description

Multiplicity of fields (Items and Arguments)

This module supports type-based handling of multiplicity, of Items (within Documents) and Arguments (in Item keyword lines).

It is for use by macros, rather than directly.

§Explanation

We use autoref specialisation to allow macros to dispatch to trait impls for Vec<T: ItemValueParseable>, Option<T> etc. as well as simply unadorned T.

For Items we have struct ItemSetSelector<Field> and trait ItemSetMethods.

ItemSetMethods is implemented for ItemSetSelector<Field> for each supported Field. So, for ItemSetSelector<T>, ItemSetSelector<Option<T>>, and ItemSetSelector<Vec<T>>. But, for just T, the impl is on &ItemSetSelector<T>.

When methods on ItemSetSelector are called, the compiler finds the specific implementation for ItemSetSelector<Option<_>> or ..Vec<_>, or, failing that, derefs and finds the blanket impl on &ItemSetSelector<T>.

For Arguments we have ArgumentSetSelector and ArgumentSetMethods, which work similarly.

Structs§

ArgumentSetSelector
Helper type that allows us to select an impl of ArgumentSetMethods
ItemSetSelector
Helper type that allows us to select an impl of ItemSetMethods

Traits§

ArgumentSetMethods
Method for handling some multiplicity of Arguments
ItemSetMethods
Methods for handling some multiplicity of Items