Struct logos::Skip

source ·
pub struct Skip;
Expand description

Type that can be returned from a callback, informing the Lexer, to skip current token match. See also logos::skip.

Example

use logos::{Logos, Skip};

#[derive(Logos, Debug, PartialEq)]
enum Token<'a> {
    // We will treat "abc" as if it was whitespace.
    // This is identical to using `logos::skip`.
    #[regex(" |abc", |_| Skip)]
    #[error]
    Error,

    #[regex("[a-zA-Z]+")]
    Text(&'a str),
}

let tokens: Vec<_> = Token::lexer("Hello abc world").collect();

assert_eq!(
    tokens,
    &[
        Token::Text("Hello"),
        Token::Text("world"),
    ],
);

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.