4
4
//! sentinel value that can be used to learn about the demangled version of a
5
5
//! symbol name. The demangled representation will be the same as the original
6
6
//! if it doesn't look like a mangled symbol name.
7
+ //!
8
+ //! # Examples
9
+ //!
10
+ //! ```
11
+ //! use rustc_demangle::demangle;
12
+ //!
13
+ //! assert_eq!(demangle("_ZN4testE").to_string(), "test");
14
+ //! assert_eq!(demangle("_ZN3foo3barE").to_string(), "foo::bar");
15
+ //! assert_eq!(demangle("foo").to_string(), "foo");
16
+ //! ```
7
17
8
18
#![ no_std]
9
19
#![ deny( missing_docs) ]
@@ -32,6 +42,16 @@ pub struct Demangle<'a> {
32
42
/// `Symbol` which is in turn resolved from a `Frame`) and then writes the
33
43
/// de-mangled version into the given `writer`. If the symbol does not look like
34
44
/// a mangled symbol, it is still written to `writer`.
45
+ ///
46
+ /// # Examples
47
+ ///
48
+ /// ```
49
+ /// use rustc_demangle::demangle;
50
+ ///
51
+ /// assert_eq!(demangle("_ZN4testE").to_string(), "test");
52
+ /// assert_eq!(demangle("_ZN3foo3barE").to_string(), "foo::bar");
53
+ /// assert_eq!(demangle("foo").to_string(), "foo");
54
+ /// ```
35
55
36
56
// All rust symbols are in theory lists of "::"-separated identifiers. Some
37
57
// assemblers, however, can't handle these characters in symbol names. To get
@@ -41,7 +61,7 @@ pub struct Demangle<'a> {
41
61
// 2. For each element of the path, emit the length plus the element
42
62
// 3. End the path with "E"
43
63
//
44
- // For example, "_ZN4testE" => "test" and "_ZN3foo3bar " => "foo::bar".
64
+ // For example, "_ZN4testE" => "test" and "_ZN3foo3barE " => "foo::bar".
45
65
//
46
66
// We're the ones printing our backtraces, so we can't rely on anything else to
47
67
// demangle our symbols. It's *much* nicer to look at demangled symbols, so
0 commit comments