Skip to main content

readable_name

Function readable_name 

Source
pub fn readable_name(raw: &str) -> String
Expand description

Returns a readable name from a raw identifier that may be a Clang USR.

§USR format

USRs follow the pattern c:…@…@name#…. The last @‑delimited segment contains the symbol’s base name, optionally followed by #… encoding template arguments and qualifiers.

§Strategy

  1. If raw does not contain @, it is already a plain name and is returned unchanged.
  2. Otherwise, the substring after the last @ is taken.
  3. Everything from the first # in that substring is discarded.

§Examples

assert_eq!(readable_name("c:@F@main"), "main");
assert_eq!(readable_name("c:@S@MyClass@F@method"), "method");
assert_eq!(
    readable_name("c:@S@MyClass@F@MyClass#&1$@S@MyClass#"),
    "MyClass"
);
assert_eq!(readable_name("already_clean"), "already_clean");
assert_eq!(readable_name(""), "");