mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-12-18 08:33:07 +00:00
31 lines
603 B
Rust
31 lines
603 B
Rust
|
use std::num::NonZeroUsize;
|
||
|
|
||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||
|
pub struct ElementId(pub usize);
|
||
|
|
||
|
// pub struct ElementId(pub NonZeroUsize);
|
||
|
|
||
|
// impl Default for ElementId {
|
||
|
// fn default() -> Self {
|
||
|
// Self(NonZeroUsize::new(1).unwrap())
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
pub struct ElementArena {
|
||
|
counter: usize,
|
||
|
}
|
||
|
|
||
|
impl Default for ElementArena {
|
||
|
fn default() -> Self {
|
||
|
Self { counter: 1 }
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl ElementArena {
|
||
|
pub fn next(&mut self) -> ElementId {
|
||
|
let id = self.counter;
|
||
|
self.counter += 1;
|
||
|
ElementId(id)
|
||
|
}
|
||
|
}
|