[−][src]Struct rustdoc::html::highlight::Classifier

struct Classifier<'sess> {
    lexer: StringReader<'sess>,
    peek_token: Option<Token>,
    source_map: &'sess SourceMap,
    in_attribute: bool,
    in_macro: bool,
    in_macro_nonterminal: bool,
}

Processes a program (nested in the internal lexer), classifying strings of text by highlighting category (Class). Calls out to a Writer to write each span of text in sequence.

Fields

lexer: StringReader<'sess>peek_token: Option<Token>source_map: &'sess SourceMapin_attribute: boolin_macro: boolin_macro_nonterminal: bool

Implementations

impl<'sess> Classifier<'sess>[src]

fn new(sess: &ParseSess, source_file: Lrc<SourceFile>) -> Classifier<'_>[src]

fn try_next_token(&mut self) -> Result<Token, HighlightError>[src]

Gets the next token out of the lexer.

fn peek(&mut self) -> Result<&Token, HighlightError>[src]

fn write_source<W: Writer>(&mut self, out: &mut W) -> Result<(), HighlightError>[src]

Exhausts the lexer writing the output into out.

The general structure for this method is to iterate over each token, possibly giving it an HTML span with a class specifying what flavor of token is used. All source code emission is done as slices from the source map, not from the tokens themselves, in order to stay true to the original source.

fn write_token<W: Writer>(
    &mut self,
    out: &mut W,
    token: Token
) -> Result<(), HighlightError>
[src]

fn snip(&self, sp: Span) -> String[src]

Auto Trait Implementations

impl<'sess> !RefUnwindSafe for Classifier<'sess>

impl<'sess> !Send for Classifier<'sess>

impl<'sess> !Sync for Classifier<'sess>

impl<'sess> Unpin for Classifier<'sess>

impl<'sess> !UnwindSafe for Classifier<'sess>

Blanket Implementations

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

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

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

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[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<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithConstness for T[src]