[][src]Struct erl_tokenize::tokens::AtomToken

pub struct AtomToken { /* fields omitted */ }

Atom token.

Examples

use erl_tokenize::Position;
use erl_tokenize::tokens::AtomToken;

let pos = Position::new();

// Ok
assert_eq!(AtomToken::from_text("foo", pos.clone()).unwrap().value(), "foo");
assert_eq!(AtomToken::from_text("foo  ", pos.clone()).unwrap().value(), "foo");
assert_eq!(AtomToken::from_text("'foo'", pos.clone()).unwrap().value(), "foo");
assert_eq!(AtomToken::from_text(r"'f\x6Fo'", pos.clone()).unwrap().value(), "foo");

// Err
assert!(AtomToken::from_text("  foo", pos.clone()).is_err());
assert!(AtomToken::from_text("123", pos.clone()).is_err());

Methods

impl AtomToken[src]

pub fn from_value(value: &str, pos: Position) -> Self[src]

Makes a new AtomToken instance from the value.

Examples

use erl_tokenize::Position;
use erl_tokenize::tokens::AtomToken;

let pos = Position::new();
assert_eq!(AtomToken::from_value("foo", pos.clone()).text(), "'foo'");
assert_eq!(AtomToken::from_value("foo's", pos.clone()).text(), r"'foo\'s'");

pub fn from_text(text: &str, pos: Position) -> Result<Self>[src]

Tries to convert from any prefixes of the input text to an AtomToken.

pub fn value(&self) -> &str[src]

Returns the value of this token.

Examples

use erl_tokenize::Position;
use erl_tokenize::tokens::AtomToken;

let pos = Position::new();

assert_eq!(AtomToken::from_text("foo", pos.clone()).unwrap().value(), "foo");
assert_eq!(AtomToken::from_text("'foo'", pos.clone()).unwrap().value(), "foo");
assert_eq!(AtomToken::from_text(r"'f\x6Fo'", pos.clone()).unwrap().value(), "foo");

pub fn text(&self) -> &str[src]

Returns the original textual representation of this token.

Examples

use erl_tokenize::Position;
use erl_tokenize::tokens::AtomToken;

let pos = Position::new();

assert_eq!(AtomToken::from_text("foo", pos.clone()).unwrap().text(), "foo");
assert_eq!(AtomToken::from_text("'foo'", pos.clone()).unwrap().text(), "'foo'");
assert_eq!(AtomToken::from_text(r"'f\x6Fo'", pos.clone()).unwrap().text(), r"'f\x6Fo'");

Trait Implementations

impl PositionRange for AtomToken[src]

impl From<AtomToken> for LexicalToken[src]

impl From<AtomToken> for Token[src]

impl Clone for AtomToken[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for AtomToken[src]

impl Display for AtomToken[src]

Auto Trait Implementations

impl Send for AtomToken

impl Sync for AtomToken

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]