brk: first commit

This commit is contained in:
nym21
2025-02-23 01:25:15 +01:00
parent 8c3f519016
commit 19cf34f9d4
266 changed files with 225 additions and 1268 deletions

31
_src/structs/counter.rs Normal file
View File

@@ -0,0 +1,31 @@
use allocative::Allocative;
use bincode::{Decode, Encode};
use derive_deref::{Deref, DerefMut};
use serde::{Deserialize, Serialize};
#[derive(
Debug, Deref, DerefMut, Default, Clone, Copy, Encode, Decode, Serialize, Deserialize, Allocative,
)]
pub struct Counter(u32);
impl Counter {
#[inline(always)]
pub fn increment(&mut self) {
self.0 += 1;
}
#[inline(always)]
pub fn decrement(&mut self) {
self.0 -= 1;
}
#[inline(always)]
pub fn reset(&mut self) {
self.0 = 0;
}
#[inline(always)]
pub fn inner(&self) -> u32 {
self.0
}
}