swift-demangler
Idiomatic Rust bindings for Swift symbol demangling.
This crate wraps a vendored copy of the Swift runtime's demangling code, providing safe, ergonomic Rust APIs for:
- Demangling Swift symbols to human-readable strings
- Traversing the full parse tree with proper lifetime management
- Extracting function metadata (async, throws, parameters, return type, etc.)
Usage
Add to your Cargo.toml:
[]
= "0.1"
Simple Demangling
use demangle;
let demangled = demangle.unwrap;
assert_eq!;
Structured Symbol Analysis
use ;
let ctx = new;
if let Some = parse
Node Tree Traversal
For detailed analysis, the raw module provides direct access to the parse tree:
use Context;
use ;
let ctx = new;
if let Some = parse
Building
Default (Bundled)
By default, the crate builds the C++ library from source using CMake:
This requires:
- CMake 3.16+
- C++20 compiler (Clang or GCC)
Pre-built Library
To link against a pre-built library instead of building from source:
# Build the C library separately
# Link the Rust crate to the pre-built library
SWIFT_DEMANGLE_DIR=build/lib
Feature Flags
bundled(default) - Build the C++ library from source using CMakecli- Build theswift-demanglercommand-line tool
CLI Tool
License
This crate is licensed under the Apache License 2.0.
It includes vendored code from the Swift and LLVM projects:
- Swift: Apache License 2.0 - see
swift-demangling/vendor/LICENSE-Swift.txt - LLVM: Apache License 2.0 with LLVM Exceptions - see
swift-demangling/vendor/LICENSE-LLVM.txt