Add counter type
This commit is contained in:
@@ -1 +1,2 @@
|
||||
pub mod macros;
|
||||
pub mod types;
|
||||
|
||||
21
src/types.rs
Normal file
21
src/types.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
#[derive(Debug)]
|
||||
pub struct CounterU32 {
|
||||
v: u32,
|
||||
}
|
||||
|
||||
impl CounterU32 {
|
||||
#[inline(always)]
|
||||
pub fn new() -> Self {
|
||||
Self { v: 0 }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn inc(&mut self) {
|
||||
self.v += 1
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn ingest(&mut self, rhs: Self) {
|
||||
self.v += rhs.v
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user