pub struct Pattern { /* private fields */ }Expand description
One authored pattern: what the definition is documented with, the shape it is invoked in, and the body that shape expands into.
§Authority
The body is the caller’s token material and nothing here reads it. It names seats by the names the shape declares them under, and the two reaches by the names this home publishes. A body naming anything else is a defect the consumer’s own compiler reports at the site that adopted it, because a producer that checked it would be legislating a meaning it does not own.
Implementations§
Source§impl Pattern
impl Pattern
Sourcepub fn declared(
note: &str,
parts: Vec<Part>,
body: GeneratedTree,
) -> Result<Self, StampError>
pub fn declared( note: &str, parts: Vec<Part>, body: GeneratedTree, ) -> Result<Self, StampError>
Declare one pattern: the sentence its definition is documented with, the shape it is invoked in, and the body that shape expands into.
§Errors
Returns StampError::SeatNameDoubled where two seats carry one name, StampError::PatternEmpty where no part was stated, and StampError::PatternUnbounded where the parts outgrow the declared magnitude.
The namespace is closed before the magnitude, because a collision is a defect in what was declared and a caller repairing a magnitude first would repair the collision second.
Sourcepub fn parts(&self) -> &NonEmpty<Part, PART_LIMIT>
pub fn parts(&self) -> &NonEmpty<Part, PART_LIMIT>
The declared shape, in the order it is written; structurally at least one part.
§Ordering
This order is meaning: a matcher and every invocation are walks over it, so the same parts stated in another order are another grammar.
Sourcepub const fn body(&self) -> &GeneratedTree
pub const fn body(&self) -> &GeneratedTree
The body the shape expands into.
Sourcepub fn seats(&self) -> impl Iterator<Item = &Seat>
pub fn seats(&self) -> impl Iterator<Item = &Seat>
The seats of the shape, in the order a site supplies arguments for them.
Sourcepub fn seat_count(&self) -> usize
pub fn seat_count(&self) -> usize
How many seats the shape declares.