1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
//! # ast-demangle //! //! Parses mangled names and produces structured results. //! //! Example: //! //! ```rust //! use ast_demangle::rust_v0::display::Style; //! use ast_demangle::rust_v0::{Identifier, Path, Symbol}; //! //! let mangled_name = "_RNvNtCs6GSVXm7oiwY_5regex4utf811decode_utf8.llvm.1119170478327948870"; //! let (symbol, suffix) = Symbol::parse_from_str(mangled_name).unwrap(); //! //! // The suffix is returned. //! assert_eq!(suffix, ".llvm.1119170478327948870"); //! //! // The default style for displaying is the long format. //! assert_eq!(format!("{}", symbol), "regex[4df147058689a776]::utf8::decode_utf8"); //! //! // To omit the crate hash, use the alternate display format. //! assert_eq!(format!("{:#}", symbol), "regex::utf8::decode_utf8"); //! //! // Use `Symbol::display` and `Style` to specify the display style explicitly. //! //! assert_eq!(format!("{}", symbol.display(Style::Short)), "decode_utf8"); //! assert_eq!(format!("{}", symbol.display(Style::Normal)), "regex::utf8::decode_utf8"); //! //! assert_eq!( //! format!("{}", symbol.display(Style::Long)), //! "regex[4df147058689a776]::utf8::decode_utf8" //! ); //! //! // You can access the structure of the demangled symbol. //! //! assert_eq!( //! symbol, //! Symbol { //! version: None, //! path: Path::Nested { //! namespace: b'v', //! path: Path::Nested { //! namespace: b't', //! path: Path::CrateRoot(Identifier { //! disambiguator: 0x4df1_4705_8689_a776, //! name: "regex".into() //! }) //! .into(), //! name: Identifier { //! disambiguator: 0, //! name: "utf8".into() //! } //! } //! .into(), //! name: Identifier { //! disambiguator: 0, //! name: "decode_utf8".into() //! } //! } //! .into(), //! instantiating_crate: None //! } //! ); //! ``` #![warn( clippy::clone_on_ref_ptr, clippy::needless_borrow, clippy::pedantic, clippy::rc_buffer, clippy::suboptimal_flops, clippy::useless_let_if_seq )] #![allow(clippy::non_ascii_literal)] pub mod rust_v0;