use std::collections::HashSet;
#[derive(Default)]
pub(crate) struct RustNameTracker {
rust_names_used: HashSet<String>,
}
impl RustNameTracker {
pub(crate) fn new() -> Self {
Self::default()
}
pub(crate) fn ok_to_use_rust_name(&mut self, rust_name: &str) -> bool {
self.rust_names_used.insert(rust_name.to_string())
}
}
#[cfg(test)]
mod tests {
use super::RustNameTracker;
#[test]
fn test() {
let mut rnt = RustNameTracker::new();
assert!(rnt.ok_to_use_rust_name("a"));
assert!(!rnt.ok_to_use_rust_name("a"));
assert!(rnt.ok_to_use_rust_name("b"));
}
}