TAG TECHNOLOGY
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user