use std::sync::Mutex;
use crate::lib::{json, Value};
lazy_static::lazy_static! {
static ref COUNT: Mutex<usize> = Mutex::new(0);
}
pub fn x_unique_id_x(prefix: &str) -> String {
let mut c = COUNT.lock().unwrap();
*c += 1;
format!("{}{}", prefix, c)
}
pub fn x_unique_id(prefix: &str) -> Value {
json!(x_unique_id_x(prefix))
}
pub fn unique_id_x(prefix: &str) -> String {
x_unique_id_x(prefix)
}
pub fn unique_id(prefix: &str) -> Value {
x_unique_id(prefix)
}
#[macro_export]
macro_rules! x_unique_id_x {
() => {
$crate::x_unique_id_x("")
};
($a:expr $(,)*) => {
$crate::x_unique_id_x($a)
};
($a:expr, $($rest:tt)*) => {
$crate::x_unique_id_x($a)
};
}
#[macro_export]
macro_rules! x_unique_id {
() => {
$crate::x_unique_id("")
};
($a:expr $(,)*) => {
$crate::x_unique_id($a)
};
($a:expr, $($rest:tt)*) => {
$crate::x_unique_id($a)
};
}
#[macro_export]
macro_rules! unique_id_x {
() => {
$crate::unique_id_x("")
};
($a:expr $(,)*) => {
$crate::unique_id_x($a)
};
($a:expr, $($rest:tt)*) => {
$crate::unique_id_x($a)
};
}
#[macro_export]
macro_rules! unique_id {
() => {
$crate::unique_id("")
};
($a:expr $(,)*) => {
$crate::unique_id($a)
};
($a:expr, $($rest:tt)*) => {
$crate::unique_id($a)
};
}