Skip to main content

deconflict_ident

Function deconflict_ident 

Source
pub fn deconflict_ident(
    ident: RustIdent,
    seen: &mut HashSet<String>,
) -> RustIdent
Expand description

Make ident unique among the identifiers in seen. A collision gets the lowest free numeric suffix: Foo, Foo2, Foo3, and so on. The function adds the chosen identifier to seen. The key is the logical identifier text, so foo and Foo count as different identifiers.

Only enum variants use this function. Two variants inside one enum can collapse onto one Rust identifier. For example, foo-bar and fooBar both become FooBar.

Top-level type names do not use this function. A numeric suffix there would pick a public type name for the author, and the generator fails fast instead. See crate::lower::rename::type_renames.