MCPcopy Index your code
hub / github.com/RustPython/RustPython / mangle_name

Function mangle_name

crates/codegen/src/symboltable.rs:2795–2810  ·  view source on GitHub ↗
(class_name: Option<&str>, name: &'a str)

Source from the content-addressed store, hash-verified

2793}
2794
2795pub(crate) fn mangle_name<'a>(class_name: Option<&str>, name: &'a str) -> Cow<'a, str> {
2796 let class_name = match class_name {
2797 Some(n) => n,
2798 None => return name.into(),
2799 };
2800 if !name.starts_with("__") || name.ends_with("__") || name.contains('.') {
2801 return name.into();
2802 }
2803 // Strip leading underscores from class name
2804 let class_name = class_name.trim_start_matches('_');
2805 let mut ret = String::with_capacity(1 + class_name.len() + name.len());
2806 ret.push('_');
2807 ret.push_str(class_name);
2808 ret.push_str(name);
2809 ret.into()
2810}
2811
2812/// Selective mangling for type parameter scopes around generic classes.
2813/// If `mangled_names` is Some, only mangle names that are in the set;

Callers 1

maybe_mangle_nameFunction · 0.70

Calls 7

starts_withMethod · 0.80
ends_withMethod · 0.80
trim_start_matchesMethod · 0.80
containsMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45
push_strMethod · 0.45

Tested by

no test coverage detected