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

pub struct StringToken<'a> { /* fields omitted */ }

String token.

Examples

use erl_tokenize::tokens::StringToken;

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

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

Methods

impl<'a> StringToken<'a>
[src]

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

Returns the value of this token.

Examples

use erl_tokenize::tokens::StringToken;

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

Returns the original textual representation of this token.

Examples

use erl_tokenize::tokens::StringToken;

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

Trait Implementations

impl<'a> Debug for StringToken<'a>
[src]

Formats the value using the given formatter.

impl<'a> Clone for StringToken<'a>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more