Skip to main content

safe_ident

Function safe_ident 

Source
pub fn safe_ident(name: &str) -> Ident
Expand description

Build an identifier for generated code from a Python name, escaping Rust keywords so identifiers like type, match, or move don’t produce invalid Rust. Keywords that cannot be raw identifiers (self, Self, super, crate) get a trailing underscore instead — except self, which is left as-is so method receivers keep working.