#[non_exhaustive]pub enum Pick<K> {
}Expand description
Where a field of an archetype is found among a node’s children.
Positions count the node’s significant children: every child node and
every token that is not trivia (whitespace and comments never count). List
picks (All, Nodes, AllKind,
Range, AllAfter,
Between, and Label) select every match,
splice the children of container kinds in place, and (except AllKind,
Nodes, and Label) leave out skip kinds such as , and ; (both
declared in the Mapping). Used where one child is
expected, a list pick takes its first match.
A pick that finds nothing makes the field absent: optional fields are then
left out, and required ones become an error node plus a
MissingField problem.
§Examples
use lower_lang::Pick;
// `let NAME = VALUE ;` in a tree without labels: the name is the first
// identifier, the value is whatever follows `=`.
let ident = 7u16; // the language's IDENT kind
let eq = 9u16; // its `=` kind
let name = Pick::Kind(ident);
let value = Pick::After(eq);
assert_ne!(name, value);
assert_eq!(Pick::<u16>::default(), Pick::Absent);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Absent
The construct never has this field.
Label(u16)
The child (or, as a list, every child) whose host-provided field label
is this id. Needs a Labeler; without one it finds nothing.
Nth(u16)
The n-th significant child (0-based).
Back(u16)
The n-th significant child from the end (Back(0) is the last).
NthNode(u16)
The n-th child node (tokens not counted).
Kind(K)
The first significant child of this kind.
KindNth(K, u16)
The n-th significant child of this kind.
First(K)
The first significant child, if it is of this kind (a leading ::, a
leading keyword).
After(K)
The first significant child after the first child of this kind (the
value after =, the return type after ->).
Before(K)
The significant child just before the first child of this kind (the
key before =>, the last item before )).
All
List: every significant child that is not a skip kind.
Nodes
List: every child node.
AllKind(K)
List: every significant child of this kind.
Range(u16, u16)
List: the significant children from position from up to back
positions before the end (Range(1, 1) is everything between a node’s
first and last child, such as the items between ( and )).
AllAfter(K)
List: every significant child after the first child of this kind.
Between(K, K)
List: the significant children after the first child of the first kind and before the next child of the second kind (or the end).