[][src]Struct erl_tokenize::tokens::CommentToken

pub struct CommentToken { /* fields omitted */ }

Comment token.

Examples

use erl_tokenize::Position;
use erl_tokenize::tokens::CommentToken;

let pos = Position::new();

// Ok
assert_eq!(CommentToken::from_text("%", pos.clone()).unwrap().value(), "");
assert_eq!(CommentToken::from_text("%% foo ", pos.clone()).unwrap().value(), "% foo ");

// Err
assert!(CommentToken::from_text("  % foo", pos.clone()).is_err());

Methods

impl CommentToken[src]

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

Makes a new CommentToken instance from the value.

Examples

use erl_tokenize::Position;
use erl_tokenize::tokens::CommentToken;

let pos = Position::new();
assert_eq!(CommentToken::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 CommentToken.

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

Returns the value of this token.

Examples

use erl_tokenize::Position;
use erl_tokenize::tokens::CommentToken;

let pos = Position::new();

assert_eq!(CommentToken::from_text("%", pos.clone()).unwrap().value(), "");
assert_eq!(CommentToken::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::CommentToken;

let pos = Position::new();

assert_eq!(CommentToken::from_text("%", pos.clone()).unwrap().text(), "%");
assert_eq!(CommentToken::from_text("%% foo ", pos.clone()).unwrap().text(), "%% foo ");

Trait Implementations

impl PositionRange for CommentToken[src]

impl Clone for CommentToken[src]

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

Performs copy-assignment from source. Read more

impl From<CommentToken> for HiddenToken[src]

impl From<CommentToken> for Token[src]

impl Display for CommentToken[src]

impl Debug for CommentToken[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]