Add a standalone error type for try_demangle
diff --git a/src/lib.rs b/src/lib.rs
index 892f1bd..b46246a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -127,6 +127,12 @@
}
}
+/// Error returned from the `try_demangle` function below when demangling fails.
+#[derive(Debug, Clone)]
+pub struct TryDemangleError {
+ _priv: (),
+}
+
/// The same as `demangle`, except return an `Err` if the string does not appear
/// to be a Rust symbol, rather than "demangling" the given string as a no-op.
///
@@ -141,12 +147,12 @@
/// // While `demangle` will just pass the non-symbol through as a no-op.
/// assert_eq!(rustc_demangle::demangle(not_a_rust_symbol).as_str(), not_a_rust_symbol);
/// ```
-pub fn try_demangle(s: &str) -> Result<Demangle, ()> {
+pub fn try_demangle(s: &str) -> Result<Demangle, TryDemangleError> {
let sym = demangle(s);
if sym.valid {
Ok(sym)
} else {
- Err(())
+ Err(TryDemangleError { _priv: () })
}
}