terrazzo-client 0.2.8

A simple macro to clone variables before passing them into a `move` closure or async block.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::sync::atomic::AtomicI32;
use std::sync::atomic::Ordering::SeqCst;

#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct ConsumerId(i32);

impl ConsumerId {
    pub fn new() -> Self {
        static NEXT: AtomicI32 = AtomicI32::new(1);
        Self(NEXT.fetch_add(1, SeqCst))
    }
}

impl std::fmt::Display for ConsumerId {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{:#x}", self.0)
    }
}