Crates.io | ast-demangle |
lib.rs | ast-demangle |
version | 0.3.1 |
source | src |
created_at | 2021-05-15 07:18:17.597947 |
updated_at | 2022-10-23 05:43:19.79085 |
description | Parses mangled names and produces structured results. |
homepage | |
repository | https://github.com/EFanZh/ast-demangle |
max_upload_size | |
id | 397730 |
size | 284,668 |
Parses mangled names and produces structured results.
Example:
use ast_demangle::rust_v0::{DisplayStyle, Identifier, Path, Symbol};
use std::borrow::Cow;
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, "");
// 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 `DisplayStyle` to specify the display style explicitly.
assert_eq!(format!("{}", symbol.display(DisplayStyle::Short)), "decode_utf8");
assert_eq!(format!("{}", symbol.display(DisplayStyle::Normal)), "regex::utf8::decode_utf8");
assert_eq!(
format!("{}", symbol.display(DisplayStyle::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: Cow::Borrowed("regex")
})
.into(),
identifier: Identifier {
disambiguator: 0,
name: Cow::Borrowed("utf8")
}
}
.into(),
identifier: Identifier {
disambiguator: 0,
name: Cow::Borrowed("decode_utf8")
}
}
.into(),
instantiating_crate: None,
vendor_specific_suffix: Some(".llvm.1119170478327948870"),
}
);