pub struct FormatSink<'a> { /* private fields */ }Expand description
The writer a format callback appends to, carrying the FormatStyle it is
rendering under.
A wrapper rather than an extra parameter, so that a container passing its writer to an element descriptor passes the style with it and cannot forget to.
Implementations§
Source§impl<'a> FormatSink<'a>
impl<'a> FormatSink<'a>
Sourcepub fn display(out: &'a mut dyn Write) -> FormatSink<'a>
pub fn display(out: &'a mut dyn Write) -> FormatSink<'a>
A sink in the program’s own rendering.
Sourcepub fn debug(out: &'a mut dyn Write) -> FormatSink<'a>
pub fn debug(out: &'a mut dyn Write) -> FormatSink<'a>
A sink in the debugger’s rendering.
Sourcepub fn style(&self) -> FormatStyle
pub fn style(&self) -> FormatStyle
The style this sink renders under.
Sourcepub fn styled(out: &'a mut dyn Write, style: FormatStyle) -> FormatSink<'a>
pub fn styled(out: &'a mut dyn Write, style: FormatStyle) -> FormatSink<'a>
A sink over out in a style read off another one.
For the callbacks that render a part into a scratch String before
placing it — map_format orders its entries by key and has to have them
rendered to place them (ADR-138 decision 4). Such a callback holds its
style across the buffer and rebuilds a sink around it,
which is what keeps a Map[Text, Text] quoting its keys and values in
the debugger, exactly as a Vec[Text] does without needing a buffer at
all.
Every scratch buffer is a place the style could be dropped, and dropping
it is silent — the value still renders, just in the other rendering. The
style is Copy so that carrying it across is the easy thing to write.