TAG TECHNOLOGY

This commit is contained in:
2025-08-14 12:21:26 -04:00
parent 4d68fa476d
commit e41970287d
19 changed files with 267 additions and 165 deletions

View File

@@ -4,11 +4,11 @@
/// point to something valid, although duplicate
/// gets around this if needed
#[derive(Eq, Hash, PartialEq, Debug)]
pub struct ID(u64);
pub struct Id(u64);
#[derive(Default)]
pub struct IDTracker {
free: Vec<ID>,
free: Vec<Id>,
cur: u64,
}
@@ -18,22 +18,22 @@ impl IDTracker {
}
#[allow(clippy::should_implement_trait)]
pub fn next(&mut self) -> ID {
pub fn next(&mut self) -> Id {
if let Some(id) = self.free.pop() {
return id;
}
let id = ID(self.cur);
let id = Id(self.cur);
self.cur += 1;
id
}
#[allow(dead_code)]
pub fn free(&mut self, id: ID) {
pub fn free(&mut self, id: Id) {
self.free.push(id);
}
}
impl ID {
impl Id {
/// this must be used carefully to make sure
/// all IDs are still valid references;
/// named weirdly to indicate this.