[−][src]Struct erl_tokenize::tokens::AtomToken
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]
fn start_position(&self) -> Position
[src]
fn end_position(&self) -> Position
[src]
impl Clone for AtomToken
[src]
fn clone(&self) -> AtomToken
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl From<AtomToken> for LexicalToken
[src]
impl From<AtomToken> for Token
[src]
impl Display for AtomToken
[src]
impl Debug for AtomToken
[src]
Auto Trait Implementations
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,