[−][src]Struct erl_tokenize::tokens::VariableToken
Variable token.
Examples
use erl_tokenize::Position; use erl_tokenize::tokens::VariableToken; let pos = Position::new(); // Ok assert_eq!(VariableToken::from_text("Foo", pos.clone()).unwrap().value(), "Foo"); assert_eq!(VariableToken::from_text("_ ", pos.clone()).unwrap().value(), "_"); assert_eq!(VariableToken::from_text("_foo@bar", pos.clone()).unwrap().value(), "_foo@bar"); // Err assert!(VariableToken::from_text("foo", pos.clone()).is_err()); assert!(VariableToken::from_text(" Foo", pos.clone()).is_err());
Methods
impl VariableToken
[src]
pub fn from_value(value: &str, pos: Position) -> Result<Self>
[src]
Makes a new VariableToken
instance from the value.
Examples
use erl_tokenize::Position; use erl_tokenize::tokens::VariableToken; let pos = Position::new(); assert_eq!(VariableToken::from_value("Foo", pos.clone()).unwrap().text(), "Foo");
pub fn from_text(text: &str, pos: Position) -> Result<Self>
[src]
Tries to convert from any prefixes of the text to a VariableToken
.
pub fn value(&self) -> &str
[src]
Returns the value of this token.
Examples
use erl_tokenize::Position; use erl_tokenize::tokens::VariableToken; let pos = Position::new(); assert_eq!(VariableToken::from_text("Foo", pos.clone()).unwrap().value(), "Foo"); assert_eq!(VariableToken::from_text("_foo ", 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::VariableToken; let pos = Position::new(); assert_eq!(VariableToken::from_text("Foo", pos.clone()).unwrap().text(), "Foo"); assert_eq!(VariableToken::from_text("_foo ", pos.clone()).unwrap().text(), "_foo");
Trait Implementations
impl PositionRange for VariableToken
[src]
fn start_position(&self) -> Position
[src]
fn end_position(&self) -> Position
[src]
impl Clone for VariableToken
[src]
fn clone(&self) -> VariableToken
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl From<VariableToken> for LexicalToken
[src]
fn from(f: VariableToken) -> Self
[src]
impl From<VariableToken> for Token
[src]
fn from(f: VariableToken) -> Self
[src]
impl Display for VariableToken
[src]
impl Debug for VariableToken
[src]
Auto Trait Implementations
impl Send for VariableToken
impl Sync for VariableToken
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,