rustdoc::html::highlight

Function string

Source
fn string<T: Display>(
    out: &mut impl Write,
    text: T,
    klass: Option<Class>,
    href_context: &Option<HrefContext<'_, '_>>,
    open_tag: bool,
)
Expand description

Called for a span of text. If the text should be highlighted differently from the surrounding text, then the Class argument will be a value other than None.

The following sequences of callbacks are equivalent:

    enter_span(Foo), string("text", None), exit_span()
    string("text", Foo)

The latter can be thought of as a shorthand for the former, which is more flexible.

Note that if context is not None and that the given klass contains a Span, the function will then try to find this span in the span_correspondence_map. If found, it’ll then generate a link for this element (which corresponds to where its definition is located).