pub struct Counter(/* private fields */);
Expand description
An incrementing counter for generating unique ids.
This can be used safely from multiple threads.
The counter will overflow if next()
is called 2^64 - 2 times.
If this is possible for your application, and reuse would be undesirable,
use something else.
Implementations§
Source§impl Counter
impl Counter
Sourcepub const unsafe fn new_unchecked(init: u64) -> Counter
pub const unsafe fn new_unchecked(init: u64) -> Counter
Sourcepub fn next_nonzero(&self) -> NonZeroU64
pub fn next_nonzero(&self) -> NonZeroU64
Return the next value, as a NonZeroU64
.
Auto Trait Implementations§
impl !Freeze for Counter
impl RefUnwindSafe for Counter
impl Send for Counter
impl Sync for Counter
impl Unpin for Counter
impl UnwindSafe for Counter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
Source§fn round_into(self) -> U
fn round_into(self) -> U
Performs the conversion.