Skip to main content

Percent

Struct Percent 

Source
pub struct Percent<S = (), C = (), Lang: ?Sized = ()> { /* private fields */ }
Expand description

The % punctuator

Implementations§

Source§

impl Percent

Source

pub fn try_parse<'inp, L, Ctx, Lang: ?Sized, Cmpl>( inp: &mut InputRef<'inp, '_, L, Ctx, Lang, Cmpl>, ) -> Result<ParseAttempt<Percent<L::Span, (), Lang>>, <Ctx::Emitter as Emitter<'inp, L, Lang>>::Error>
where L: Lexer<'inp>, L::Token: PunctuatorToken<'inp>, Ctx: ParseContext<'inp, L, Lang>, Cmpl: SurfaceIncomplete<'inp, L, Ctx, Lang>, <Ctx::Emitter as Emitter<'inp, L, Lang>>::Error: From<UnexpectedEot<L::Offset, Lang>>,

Available on crate feature punct only.

A parser that parses a token and returns a Percent instance if it matches.

If the function returns Ok(ParseAttempt::Decline), it means the next token does not match, and promises no valid token is consumed; a terminal scanner stop is an error, never a Decline.

Lang is read off the input, so an unbranded grammar writes the same call as a branded one.

Source

pub fn parse<'inp, L, Ctx, Lang, Cmpl>( inp: &mut InputRef<'inp, '_, L, Ctx, Lang, Cmpl>, ) -> Result<Percent<L::Span, (), Lang>, <Ctx::Emitter as Emitter<'inp, L, Lang>>::Error>
where L: Lexer<'inp>, L::Token: PunctuatorToken<'inp>, Ctx: ParseContext<'inp, L, Lang>, Cmpl: SurfaceIncomplete<'inp, L, Ctx, Lang>, <Ctx::Emitter as Emitter<'inp, L, Lang>>::Error: From<UnexpectedEot<L::Offset, Lang>> + From<UnexpectedToken<'inp, L::Token, <L::Token as Token<'inp>>::Kind, L::Span, Lang>>, Lang: ?Sized,

Available on crate feature punct only.

A parser that parses a token and returns a Percent instance if it matches.

Lang is read off the input, so an unbranded grammar writes the same call as a branded one.

Source§

impl Percent<()>

Source

pub const UNIT: Self

A unit instance of the % punctuator.

Source

pub const fn unit() -> Self

Returns a unit instance of the % punctuator.

Source§

impl Percent

Source

pub const fn raw() -> &'static str

Returns the raw string literal of the % punctuator.

Source§

impl<S> Percent<S>

Source

pub const fn new(span: S) -> Self

Creates a new punctuator with the given span.

Source§

impl<S, C> Percent<S, C>

Source

pub const fn with_content(span: S, content: C) -> Self

Creates a new % punctuator with the given span and content.

Source§

impl<S, C, Lang: ?Sized> Percent<S, C, Lang>

Source

pub fn change_language<N: ?Sized>(self) -> Percent<S, C, N>

Changes the language type of the % punctuator.

Source

pub const fn change_language_const<N: ?Sized>(self) -> Percent<S, C, N>
where S: Copy, C: Copy,

Changes the language type of the % punctuator.

Source

pub const fn as_str(&self) -> &'static str

Returns the raw string literal of the % punctuator.

Source

pub const fn span(&self) -> &S

Returns the span of the % punctuator.

Source

pub const fn content(&self) -> &C

Returns a reference to the content of the % punctuator.

Trait Implementations§

Source§

impl<S, C, Lang: ?Sized> AsRef<str> for Percent<S, C, Lang>

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<S, C, Lang: ?Sized> AsSpan<S> for Percent<S, C, Lang>

Source§

fn as_span(&self) -> &S

Consumes this element and returns the owned source span. Read more
Source§

impl<S, C, Lang: ?Sized> Borrow<str> for Percent<S, C, Lang>

Source§

fn borrow(&self) -> &str

Immutably borrows from an owned value. Read more
Source§

impl<'inp, T, S, C, Lang> Check<T> for Percent<S, C, Lang>
where T: PunctuatorToken<'inp> + ?Sized + 'inp, Lang: ?Sized,

Source§

fn check(&self, target: &T) -> bool

Check against the target. Read more
Source§

fn by_ref(&self) -> &ByRef<Self>

Create a reference check wrapper.
Source§

impl<S: Clone, C: Clone, Lang: Clone + ?Sized> Clone for Percent<S, C, Lang>

Source§

fn clone(&self) -> Percent<S, C, Lang>

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<S: Copy, C: Copy, Lang: Copy + ?Sized> Copy for Percent<S, C, Lang>

Source§

impl<S: Debug, C: Debug, Lang: Debug + ?Sized> Debug for Percent<S, C, Lang>

Source§

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

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

impl<S, C, Lang: ?Sized> Display for Percent<S, C, Lang>

Source§

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

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

impl<S, C, Lang: ?Sized> DisplayCompact for Percent<S, C, Lang>

Source§

type Options = ()

The options type for controlling compact formatting.
Source§

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

Formats the value in a compact, space-efficient way.
Source§

fn display<'a>(&'a self, options: &'a Self::Options) -> CompactDisplay<'a, Self>

Returns a wrapper that implements Display for compact formatting. Read more
Source§

impl<S, C, Lang: ?Sized> DisplayHuman for Percent<S, C, Lang>

Source§

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

Formats the value in a human-friendly way. Read more
Source§

fn display(&self) -> HumanDisplay<'_, Self>

Returns a wrapper that implements Display using the human-friendly format. Read more
Source§

impl<S, C, Lang: ?Sized> DisplayPretty for Percent<S, C, Lang>

Source§

type Options = ()

The options type for controlling pretty formatting.
Source§

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

Formats the value in a human-friendly, readable way.
Source§

fn display<'a>(&'a self, options: &'a Self::Options) -> PrettyDisplay<'a, Self>

Returns a wrapper that implements Display for pretty formatting. Read more
Source§

impl<S: Eq, C: Eq, Lang: Eq + ?Sized> Eq for Percent<S, C, Lang>

Source§

impl<S: Hash, C: Hash, Lang: Hash + ?Sized> Hash for Percent<S, C, Lang>

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<S, C, Lang: ?Sized> IntoComponents for Percent<S, C, Lang>

Source§

type Components = (S, C)

The tuple or struct type containing the decomposed components. Read more
Source§

fn into_components(self) -> Self::Components

Consumes this element and returns its constituent components. Read more
Source§

impl<S, C, Lang: ?Sized> IntoSpan<S> for Percent<S, C, Lang>

Source§

fn into_span(self) -> S

Consumes this element and returns the owned source span. Read more
Source§

impl<S: PartialEq, C: PartialEq, Lang: PartialEq + ?Sized> PartialEq for Percent<S, C, Lang>

Source§

fn eq(&self, other: &Percent<S, C, Lang>) -> bool

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

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

Inequality operator !=. Read more
Source§

impl<S, C, Lang: ?Sized> PartialEq<Percent<S, C, Lang>> for str

Source§

fn eq(&self, other: &Percent<S, C, Lang>) -> bool

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

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

Inequality operator !=. Read more
Source§

impl<S, C, Lang: ?Sized> PartialEq<str> for Percent<S, C, Lang>

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl<S, C, Lang: ?Sized> PartialOrd<Percent<S, C, Lang>> for str

Source§

fn partial_cmp(&self, other: &Percent<S, C, Lang>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<S, C, Lang: ?Sized> PartialOrd<str> for Percent<S, C, Lang>

Source§

fn partial_cmp(&self, other: &str) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'inp, L, S, C, Lang: ?Sized> Punctuator<'inp, L, Lang> for Percent<S, C, Lang>
where L: Lexer<'inp>, <L::Token as Token<'inp>>::Kind: From<Percent<(), (), ()>>,

Source§

fn name() -> CowStr

Returns the name of the punctuator.
Source§

fn description() -> Option<CowStr>

Returns the description of the punctuator.
Source§

fn kind() -> <L::Token as Token<'inp>>::Kind

Returns the kind of the punctuator.
Source§

fn eval(knd: &<L::Token as Token<'inp>>::Kind) -> bool
where L: Lexer<'inp>,

Evaluates whether the given token kind matches the punctuator’s kind.
Source§

fn unexpected_token( tok: Spanned<L::Token, L::Span>, ) -> UnexpectedToken<'inp, L::Token, <L::Token as Token<'inp>>::Kind, L::Span, Lang>
where L: Lexer<'inp>,

Creates an UnexpectedToken error for the punctuator.
Source§

impl<S: PartialEq, C: PartialEq, Lang: PartialEq + ?Sized> StructuralPartialEq for Percent<S, C, Lang>

Auto Trait Implementations§

§

impl<S, C, Lang> Freeze for Percent<S, C, Lang>
where S: Freeze, C: Freeze, PhantomData<Lang>: Freeze, Lang: ?Sized,

§

impl<S, C, Lang> RefUnwindSafe for Percent<S, C, Lang>

§

impl<S, C, Lang> Send for Percent<S, C, Lang>
where S: Send, C: Send, PhantomData<Lang>: Send, Lang: ?Sized,

§

impl<S, C, Lang> Sync for Percent<S, C, Lang>
where S: Sync, C: Sync, PhantomData<Lang>: Sync, Lang: ?Sized,

§

impl<S, C, Lang> Unpin for Percent<S, C, Lang>
where S: Unpin, C: Unpin, PhantomData<Lang>: Unpin, Lang: ?Sized,

§

impl<S, C, Lang> UnsafeUnpin for Percent<S, C, Lang>
where S: UnsafeUnpin, C: UnsafeUnpin, PhantomData<Lang>: UnsafeUnpin, Lang: ?Sized,

§

impl<S, C, Lang> UnwindSafe for Percent<S, C, Lang>
where S: UnwindSafe, C: UnwindSafe, PhantomData<Lang>: UnwindSafe, Lang: ?Sized,

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> Same for T

Source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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, !>

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.