[][src]Enum comment_parser::Event

pub enum Event<'a> {
    LineComment(&'a str, &'a str),
    BlockComment(&'a str, &'a str),

Events contain raw and text.

Text is the contents of the comment, while raw includes additional characters based on the type of comment, such as the comment delimiters or "start and end symbols" of the comment.

  • LineComment's raw includes the whole line.
  • BlockComment's raw includes only the block comment delimiters.

The above is only true, for events parsed by CommentParser.


let line = Event::LineComment("  // Foo Bar", " Foo Bar");
assert_eq!(line.text(), " Foo Bar");
assert_eq!(line.raw(),  "  // Foo Bar");

let block = Event::BlockComment("/* Foo\n  Bar */", " Foo\n  Bar ");
assert_eq!(block.text(), " Foo\n  Bar ");
assert_eq!(block.raw(),  "/* Foo\n  Bar */");


LineComment(&'a str, &'a str)

LineComment(raw, text)

BlockComment(&'a str, &'a str)

BlockComment(raw, text)


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

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

Returns the raw part of an Event.

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

Returns the text part of an Event.

Trait Implementations

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

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

fn fmt(&self, fmt: &mut Formatter) -> Result[src]

Renders raw as _ as both raw and text are similar.

impl<'a> PartialEq<Event<'a>> for Event<'a>[src]

impl<'a> StructuralPartialEq for Event<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Event<'a>

impl<'a> Send for Event<'a>

impl<'a> Sync for Event<'a>

impl<'a> Unpin for Event<'a>

impl<'a> UnwindSafe for Event<'a>

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

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

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.