next-web-macros 0.2.0

Provide a series of commonly used macros
Documentation
1
2
3
4
5
6
7
8
use std::sync::atomic::{AtomicU32, Ordering};

static COUNTER: AtomicU32 = AtomicU32::new(0);

pub fn unique_id() -> String {
    let val = COUNTER.fetch_add(1, Ordering::Relaxed) % 1_000;
    format!("{:03}", val) // 补零到6位
}