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.

We implement traits on a helper type struct MultiplicitySelector<Field>.

For Items we have trait ItemSetMethods.

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

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

For Arguments we have ArgumentSetMethods, and for Objects, ObjectSetMethods, which work similarly.

Structs§

MultiplicitySelector
Helper type that allows us to select an impl of ItemSetMethods etc.

Traits§

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