24 lines
405 B
Rust
24 lines
405 B
Rust
pub struct OffsetCounter {
|
|
counter: usize,
|
|
}
|
|
|
|
impl OffsetCounter {
|
|
pub fn new() -> Self {
|
|
Self { counter: 0 }
|
|
}
|
|
|
|
pub fn with_base(base: usize) -> Self {
|
|
Self { counter: base }
|
|
}
|
|
|
|
pub fn next(&mut self) -> usize {
|
|
let offset = self.counter;
|
|
self.counter += 1;
|
|
offset
|
|
}
|
|
|
|
pub fn get_count(&self) -> usize {
|
|
self.counter
|
|
}
|
|
}
|