mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-02 18:02:59 +00:00
21 lines
408 B
Rust
21 lines
408 B
Rust
use crate::shared::Shared;
|
|
|
|
thread_local! {
|
|
static VAR_ID: Shared<usize> = Shared::new(0);
|
|
}
|
|
|
|
pub fn fresh_varname() -> String {
|
|
VAR_ID.with(|id| {
|
|
*id.borrow_mut() += 1;
|
|
let i = *id.borrow();
|
|
format!("%v{i}")
|
|
})
|
|
}
|
|
|
|
pub fn fresh_param_name() -> String {
|
|
VAR_ID.with(|id| {
|
|
*id.borrow_mut() += 1;
|
|
let i = *id.borrow();
|
|
format!("%p{i}")
|
|
})
|
|
}
|