Struct rustc_demangle::v0::Printer
source · struct Printer<'a, 'b: 'a, 's> {
parser: Result<Parser<'s>, ParseError>,
out: Option<&'a mut Formatter<'b>>,
bound_lifetime_depth: u32,
}
Fields§
§parser: Result<Parser<'s>, ParseError>
The input parser to demangle from, or Err
if any (parse) error was
encountered (in order to disallow further likely-incorrect demangling).
See also the documentation on the invalid!
and parse!
macros below.
out: Option<&'a mut Formatter<'b>>
The output formatter to demangle to, or None
while skipping printing.
bound_lifetime_depth: u32
Cumulative number of lifetimes bound by for<...>
binders (‘G’),
anywhere “around” the current entity (e.g. type) being demangled.
This value is not tracked while skipping printing, as it’d be unused.
See also the documentation on the Printer::in_binder
method.
Implementations§
source§impl<'a, 'b, 's> Printer<'a, 'b, 's>
impl<'a, 'b, 's> Printer<'a, 'b, 's>
sourcefn eat(&mut self, b: u8) -> bool
fn eat(&mut self, b: u8) -> bool
Eat the given character from the parser,
returning false
if the parser errored.
sourcefn skipping_printing<F>(&mut self, f: F)where
F: FnOnce(&mut Self) -> Result,
fn skipping_printing<F>(&mut self, f: F)where F: FnOnce(&mut Self) -> Result,
Skip printing (i.e. self.out
will be None
) for the duration of the
given closure. This should not change parsing behavior, only disable the
output, but there may be optimizations (such as not traversing backrefs).
sourcefn print_backref<F>(&mut self, f: F) -> Resultwhere
F: FnOnce(&mut Self) -> Result,
fn print_backref<F>(&mut self, f: F) -> Resultwhere F: FnOnce(&mut Self) -> Result,
Print the target of a backref, using the given closure. When printing is being skipped, the backref will only be parsed, ignoring the backref’s target completely.
fn pop_depth(&mut self)
sourcefn print(&mut self, x: impl Display) -> Result
fn print(&mut self, x: impl Display) -> Result
Output the given value to self.out
(using fmt::Display
formatting),
if printing isn’t being skipped.
sourcefn print_quoted_escaped_chars(
&mut self,
quote: char,
chars: impl Iterator<Item = char>
) -> Result
fn print_quoted_escaped_chars( &mut self, quote: char, chars: impl Iterator<Item = char> ) -> Result
Output the given char
s (escaped using char::escape_debug
), with the
whole sequence wrapped in quotes, for either a char
or &str
literal,
if printing isn’t being skipped.
sourcefn print_lifetime_from_index(&mut self, lt: u64) -> Result
fn print_lifetime_from_index(&mut self, lt: u64) -> Result
Print the lifetime according to the previously decoded index.
An index of 0
always refers to '_
, but starting with 1
,
indices refer to late-bound lifetimes introduced by a binder.
sourcefn in_binder<F>(&mut self, f: F) -> Resultwhere
F: FnOnce(&mut Self) -> Result,
fn in_binder<F>(&mut self, f: F) -> Resultwhere F: FnOnce(&mut Self) -> Result,
Optionally enter a binder (‘G’) for late-bound lifetimes,
printing e.g. for<'a, 'b>
before calling the closure,
and make those lifetimes visible to it (via depth level).
sourcefn print_sep_list<F>(&mut self, f: F, sep: &str) -> Result<usize, Error>where
F: Fn(&mut Self) -> Result,
fn print_sep_list<F>(&mut self, f: F, sep: &str) -> Result<usize, Error>where F: Fn(&mut Self) -> Result,
Print list elements using the given closure and separator, until the end of the list (‘E’) is found, or the parser errors. Returns the number of elements printed.
fn print_path(&mut self, in_value: bool) -> Result
fn print_generic_arg(&mut self) -> Result
fn print_type(&mut self) -> Result
sourcefn print_path_maybe_open_generics(&mut self) -> Result<bool, Error>
fn print_path_maybe_open_generics(&mut self) -> Result<bool, Error>
A trait in a trait object may have some “existential projections”
(i.e. associated type bindings) after it, which should be printed
in the <...>
of the trait, e.g. dyn Trait<T, U, Assoc=X>
.
To this end, this method will keep the <...>
of an ‘I’ path
open, by omitting the >
, and return Ok(true)
in that case.