Classifier in rustdoc::html::highlight - Rust (original) (raw)

struct Classifier<'src> {
    tokens: PeekIter<'src>,
    in_attribute: bool,
    in_macro: bool,
    in_macro_nonterminal: bool,
    byte_pos: u32,
    file_span: Span,
    src: &'src str,
    decorations: Option<Decorations>,
}

Expand description

Processes program tokens, classifying strings of text by highlighting category (Class).

Source§

Source

Takes as argument the source code to HTML-ify, the rust edition to use and the source code file span which will be used later on by the span_correspondence_map.

Source

Convenient wrapper to create a Span from a position in the file.

Source

Concatenate colons and idents as one when possible.

Source

Wraps the tokens iteration to ensure that the byte_pos is always correct.

It returns the token’s kind, the token as a string and its byte position in the source string.

Source

Exhausts the Classifier writing the output into sink.

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.

Source

Single step of highlighting. This will classify token, but maybe also a couple of following ones as well.

before is the position of the given token in the source string and is used as “lo” byte in case we want to try to generate a link for this token using thespan_correspondence_map.

Source

Source

§

§

§

§

§

§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 168 bytes