mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-04 09:18:46 +00:00
15 lines
240 B
Rust
15 lines
240 B
Rust
|
use std::cell::Cell;
|
||
|
|
||
|
#[derive(Default)]
|
||
|
pub(crate) struct Counter {
|
||
|
value: Cell<usize>,
|
||
|
}
|
||
|
|
||
|
impl Counter {
|
||
|
pub(crate) fn increment(&self) -> usize {
|
||
|
let v = self.value.get();
|
||
|
self.value.set(v + 1);
|
||
|
v
|
||
|
}
|
||
|
}
|