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]
fn from_text(text: &'a str) -> Result<Self>
Tries to convert from any prefixes of the text to a StringToken
.
fn value(&self) -> &str
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");
fn text(&self) -> &'a str
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]
impl<'a> Clone for StringToken<'a>
[src]
fn clone(&self) -> StringToken<'a>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more