Skip to main content

GeneratedToken

Enum GeneratedToken 

Source
pub enum GeneratedToken {
    Word(String),
    Punct {
        mark: char,
        spacing: GeneratedSpacing,
    },
    Text(String),
    Group {
        delimiter: GeneratedDelimiter,
        tokens: Bounded<GeneratedToken, GENERATED_TOKEN_LIMIT>,
    },
    ByteText(Vec<u8>),
    Number(u64),
    RawIdentifier(String),
}
Expand description

One token a renderer writes.

A renderer states a literal’s value and never its spelling, and the quoting, the escaping, and the absence of a suffix are the tree’s business.

§Ordering

The roster grows at its end and nowhere else: each arm’s slot is a byte of GeneratedTree::canonical_bytes, which is what a rendered unit’s identity is derived over.

Variants§

§

Word(String)

An ordinary identifier-shaped word.

§

Punct

One punctuation character and whether it joins what follows.

Fields

§mark: char

The character.

§spacing: GeneratedSpacing

Whether it joins what follows.

§

Text(String)

A text literal, stated as its text; the quoting is the tree’s business.

§

Group

A delimited group.

Fields

§delimiter: GeneratedDelimiter

The delimiter.

§tokens: Bounded<GeneratedToken, GENERATED_TOKEN_LIMIT>

The tokens inside.

§

ByteText(Vec<u8>)

A byte-string literal’s material, written b"…".

§

Number(u64)

An unsuffixed integer literal.

§

RawIdentifier(String)

A raw identifier’s name without its r# spelling marker.

Implementations§

Source§

impl GeneratedToken

Source

pub fn word(spelling: &str) -> Self

One ordinary word.

Source

pub fn raw_identifier(name: &str) -> Self

One raw identifier, stated without its r# spelling marker.

Source

pub const fn joint(mark: char) -> Self

One punctuation mark that joins what follows.

Source

pub const fn alone(mark: char) -> Self

One punctuation mark that stands alone.

Source

pub fn text(content: &str) -> Self

One text literal.

Source

pub fn byte_text(material: &[u8]) -> Self

One byte-string literal, over the material a caller holds.

Source

pub const fn number(value: u64) -> Self

One unsuffixed integer literal.

Source

pub fn group( delimiter: GeneratedDelimiter, tokens: Vec<Self>, ) -> Result<Self, Overflow>

One delimited group.

§Errors

Returns Overflow where the group carries more tokens than the declared magnitude admits.

Trait Implementations§

Source§

impl Clone for GeneratedToken

Source§

fn clone(&self) -> GeneratedToken

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 Debug for GeneratedToken

Source§

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

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

impl Eq for GeneratedToken

Source§

impl Hash for GeneratedToken

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 GeneratedToken

Source§

fn eq(&self, other: &GeneratedToken) -> 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 GeneratedToken

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<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 = !

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.