[][src]Struct erl_tokenize::tokens::StringToken

pub struct StringToken { /* fields omitted */ }

String token.

Examples

use erl_tokenize::Position;
use erl_tokenize::tokens::StringToken;

let pos = Position::new();

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

// Err
assert!(StringToken::from_text(r#"  "foo""#, pos.clone()).is_err());

Methods

impl StringToken[src]

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

Makes a new StringToken instance from the value.

Examples

use erl_tokenize::Position;
use erl_tokenize::tokens::StringToken;

let pos = Position::new();
assert_eq!(StringToken::from_value("foo", pos.clone()).text(), r#""foo""#);

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

Tries to convert from any prefixes of the text to a StringToken.

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

Returns the value of this token.

Examples

use erl_tokenize::Position;
use erl_tokenize::tokens::StringToken;

let pos = Position::new();

assert_eq!(StringToken::from_text(r#""foo""#, pos.clone()).unwrap().value(), "foo");
assert_eq!(StringToken::from_text(r#""foo"  "#, pos.clone()).unwrap().value(), "foo");
assert_eq!(StringToken::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::StringToken;

let pos = Position::new();

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

Trait Implementations

impl PositionRange for StringToken[src]

impl From<StringToken> for LexicalToken[src]

impl From<StringToken> for Token[src]

impl Clone for StringToken[src]

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

Performs copy-assignment from source. Read more

impl Debug for StringToken[src]

impl Display for StringToken[src]

Auto Trait Implementations

impl Send for StringToken

impl Sync for StringToken

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]