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§
- Multiplicity
Selector - Helper type that allows us to select an impl of
ItemSetMethodsetc.
Traits§
- Argument
SetMethods - Method for handling some multiplicity of Arguments
- Item
SetMethods - Methods for handling some multiplicity of Items
- Object
SetMethods - Method for handling some multiplicity of Objects