simplicity-lang 0.7.0

General purpose library for processing Simplicity programs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// SPDX-License-Identifier: CC0-1.0

//! Names for type variables

use std::sync::atomic::{AtomicUsize, Ordering};

/// Global counter used to give type variables unique names.
static NEXT_ID: AtomicUsize = AtomicUsize::new(1);

/// Obtain a fresh variable name, with the given `prefix` and a unique incrementing
/// numeric suffix.
pub fn new_name(prefix: &str) -> String {
    let id = NEXT_ID.fetch_add(1, Ordering::SeqCst);
    format!("{}{:02}", prefix, id)
}