Skip to main content

Rule

Enum Rule 

Source
#[non_exhaustive]
pub enum Rule { LineComment(&'static str), Block { open: &'static str, close: &'static str, kind: u8, nested: bool, bol: bool, }, Str { open: &'static str, close: &'static str, escape: bool, multi: bool, kind: u8, }, RawStr, Interp { open: &'static str, close: &'static str, start: &'static str, }, Words(&'static [&'static str], u8), Number, Custom(fn(&str, usize, bool) -> Option<(usize, u8)>), Punct(&'static str), }
Expand description

a rule of a grammar (see the module header)

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

LineComment(&'static str)

from the text to the end of the line: a comment

§

Block

from open to close (nested: opens inside count; bol: open and close only at the start of a line, after blanks – the whole line belongs to it); may span lines

Fields

§open: &'static str
§close: &'static str
§kind: u8
§nested: bool
§bol: bool
§

Str

a string from open to close; escape: a backslash takes the next character (SY_ESCAPE); multi: may span lines

Fields

§open: &'static str
§close: &'static str
§escape: bool
§multi: bool
§kind: u8
§

RawStr

Rust raw strings: r“..“, r#”..“#, br”..“ (may span lines)

§

Interp

a string with code inside (interpolation), on one line: from open to close, a backslash takes the next character (\u{..} its hex digits and brace; SY_ESCAPE); from start (ending with ‘{’) to the ‘}’ that closes it (braces inside count) the grammar’s rules highlight code, the two delimiters SY_META

Fields

§open: &'static str
§close: &'static str
§start: &'static str
§

Words(&'static [&'static str], u8)

identifiers of a list

§

Number

number literals: 12, 0x1F, 0b101, 0o17, 1_000, 1.5e-3, suffixes (u8, f32)

§

Custom(fn(&str, usize, bool) -> Option<(usize, u8)>)

a function of its own: (line, position, at the line start after blanks) -> (bytes, kind)

§

Punct(&'static str)

single characters

Auto Trait Implementations§

§

impl Forget for Rule

§

impl Freeze for Rule

§

impl RefUnwindSafe for Rule

§

impl Send for Rule

§

impl Sync for Rule

§

impl Unpin for Rule

§

impl UnsafeUnpin for Rule

§

impl UnwindSafe for Rule

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> ErasedDestructor for T
where T: 'static,

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

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.