pub enum Constructor {
Show 14 variants
Lines,
Sections,
Csv,
Ws,
Sep,
Grid,
Matrix,
Chars,
OneOf,
Block,
Choice,
Optional,
Scan,
Repeated,
}Expand description
The name of a structural constructor — the whole of §7.5.
Every constructor is dispatched from this table and nowhere else. A
constructor with no row here would have no arity, and therefore no arity
error either: its name would become None with no diagnostic at all.
Variants§
Lines
Sections
Csv
Ws
Sep
Grid
Matrix
Chars
OneOf
Block
Choice
Optional
Scan
Repeated
repeated(P) / repeated(P, N) — legal only as a named argument of
a sections call (§7.5). It is in the table so that the name is known
and its misuse is MisplacedRepeatedTail rather than “unknown
constructor”.
Implementations§
Source§impl Constructor
impl Constructor
Sourcepub const ALL: &'static [Constructor]
pub const ALL: &'static [Constructor]
Every constructor, so a test can sweep the table — and so the editor can
offer them: completion, signature help and the parser keyword list read
this, so a name missing here is a name the editor never offers.
constructor_round_trips_keywords_and_states_its_shape is what keeps it
complete.
Sourcepub fn from_keyword(name: &str) -> Option<Self>
pub fn from_keyword(name: &str) -> Option<Self>
Parse a constructor name, or None if no §7.5 constructor is spelled
that way.
Sourcepub fn doc(self) -> &'static str
pub fn doc(self) -> &'static str
One line of §7.5, for hover (§15.2’s “method documentation”, and its parser half).
Exhaustive, and here rather than in the language server for the reason every other table is: a constructor added to §7.5 cannot ship without saying what it does, and the editor cannot describe one differently from the compiler. The wording is §7.5’s own, compressed to a line.
Sourcepub fn keyword_arg(self) -> Option<&'static str>
pub fn keyword_arg(self) -> Option<&'static str>
The one named argument this constructor takes whose value is a
keyword and not a parser — chars(P, skip: policy)’s skip: and
grid(P, ragged, fill: value)’s fill: (§7.5). None for every other
constructor.
A keyword belongs to a constructor, so the constructor is what answers
the question. Deciding it from the argument’s name alone would mint a
block item or a sections field legitimately named fill or skip
as a keyword argument, and the field would then vanish from the record
with no diagnostic.
Sourcepub fn flag_arg(self) -> Option<&'static str>
pub fn flag_arg(self) -> Option<&'static str>
The one bare keyword flag this constructor takes — the ragged of
grid(P, ragged, fill: value) (§7.5). None for every other
constructor.
The companion to Constructor::keyword_arg, and here for the same
reason: a flag belongs to a constructor, so the constructor is what
answers the question. Minting a CallArg::Flag from the bare name
would make ragged a flag in every constructor’s argument list, so
lines(ragged) would be told it had written a flag where a parser
belongs rather than that ragged is not a parser, and the word would be
reserved everywhere instead of in grid.
Trait Implementations§
Source§impl Clone for Constructor
impl Clone for Constructor
Source§fn clone(&self) -> Constructor
fn clone(&self) -> Constructor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more