[][src]Struct numid::example::NumId

pub struct NumId(_);

A numerical id generated with the numid! macro. This struct example is generated with the macro call : numid!(#[doc=…] pub struct NumId);.

Methods

impl NumId[src]

pub const INITIAL_VALUE: u64[src]

Constant defined when calling the numid! macro (0 if not defined). The firt id created (with new() or default()) will have value = INITIAL_VALUE + 1.

pub fn new() -> NumId[src]

Increment the "current value" and create a new id with value = current_value().

pub const fn value(self) -> u64[src]

Get the value of the id.

pub fn current_value() -> u64[src]

Return the "current value", the value of the last id created (with new(), default() or create_maybe()), if no id has been created, the "current value" equal initial_value().

pub const fn initial_value() -> u64[src]

Return INITIAL_VALUE.

pub fn replace_current_value(value: u64) -> bool[src]

Replace the "current value" by the value parameter if it superior. This condition is necessary for not creating multiple ids with the same value. Return true if the "current value" has been modified.

pub fn create_maybe(value: u64) -> Option<NumId>[src]

Return Some id with specified value and replace the "current value" if replace_current_value(value) is true. Return None otherwise.

pub fn create_lower(value: u64) -> NumId[src]

Create a id with a precised value, don't increment the "current value". The value must be inferior or equal as INITIAL_VALUE for not interfering with the id system.

Panics

panic if value > INITIAL_VALUE

pub const fn const_create_lower(value: u64) -> NumId[src]

Const version of create_lower, can be used in a const environnement. In a non-const environnement, give a index: out of bounds panic message, create_lower giving a more descriptive message is therefore preferred.

Panics

panic if value > INITIAL_VALUE

pub fn reproduce(self) -> NumId[src]

Return a copy of the id if the value is inferior or equal as initial_value, else return a new id and update the current_value.

Trait Implementations

impl Display for NumId[src]

impl Debug for NumId[src]

impl PartialEq<NumId> for NumId[src]

impl Eq for NumId[src]

impl Ord for NumId[src]

impl PartialOrd<NumId> for NumId[src]

impl Hash for NumId[src]

impl Copy for NumId[src]

impl StructuralPartialEq for NumId[src]

impl StructuralEq for NumId[src]

impl Octal for NumId[src]

impl Binary for NumId[src]

impl LowerHex for NumId[src]

impl UpperHex for NumId[src]

impl Clone for NumId[src]

impl Default for NumId[src]

Increment the "current value" and create a new id with value = current_value(). This is equivalent to new().

Auto Trait Implementations

impl Unpin for NumId

impl Send for NumId

impl Sync for NumId

Blanket Implementations

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

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> Into<U> for T where
    U: From<T>, 
[src]

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.

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

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

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