Skip to main content

Constructor

Enum Constructor 

Source
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

Source

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.

Source

pub fn from_keyword(name: &str) -> Option<Self>

Parse a constructor name, or None if no §7.5 constructor is spelled that way.

Source

pub fn keyword(self) -> &'static str

The source keyword for this constructor.

Source

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.

Source

pub fn keyword_arg(self) -> Option<&'static str>

The one named argument this constructor takes whose value is a keyword and not a parserchars(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.

Source

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.

Source

pub fn arg_shape(self) -> ArgShape

The shape of this constructor’s argument list (§7.5).

Trait Implementations§

Source§

impl Clone for Constructor

Source§

fn clone(&self) -> Constructor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Constructor

Source§

impl Debug for Constructor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Constructor

Source§

impl Hash for Constructor

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Constructor

Source§

fn eq(&self, other: &Constructor) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Constructor

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.