[][src]Struct druid_shell::Counter

pub struct Counter(_);

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

impl Counter[src]

pub const fn new() -> Counter[src]

Create a new counter.

pub const unsafe fn new_unchecked(init: u64) -> Counter[src]

Creates a new counter with a given starting value.

Safety

The value must not be zero.

pub fn next(&self) -> u64[src]

Return the next value.

pub fn next_nonzero(&self) -> NonZeroU64[src]

Return the next value, as a NonZeroU64.

Auto Trait Implementations

impl RefUnwindSafe for Counter

impl Send for Counter

impl Sync for Counter

impl Unpin for Counter

impl UnwindSafe for Counter

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 

impl<T> Sealed<T> for T where
    T: ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.