Skip to main content

nonconflicting_rename

Function nonconflicting_rename 

Source
fn nonconflicting_rename(label: &str, declared: &BTreeSet<String>) -> String
Expand description

Pick a deterministic, collision-aware rename for a duplicated label: the smallest integer suffix N >= 2 whose {label}-{N} is not already in declared. Boring and stable; no similarity ranking, but it steps over existing labels so the suggested fix never re-creates the clash it resolves. Among the first declared.len() + 1 candidates at least one is free (pigeonhole), so the bounded search always yields a name.