Unique

Struct Unique 

Source
pub struct Unique<I: Id> { /* private fields */ }
Expand description

A wrapper around an ID that asserts it is unique.

This takes away the implementation of Copy and Clone for an ID and forbids access to the underlying ID.

Implementations§

Source§

impl<I> Unique<I>
where <I as ConstFnBounds>::Type: Id,

Source

pub const unsafe fn new(id: I) -> Self

Create a new Unique, asserting that the given ID contained within is unique.

§Safety

The given id must be unique at the time of calling this function.

Source

pub const fn into_inner(self) -> I

Take the inner ID out of this Unique, taking away the uniqueness guarantee.

Trait Implementations§

Source§

impl<I: Debug + Id> Debug for Unique<I>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<I: PartialEq + Id> PartialEq for Unique<I>

Source§

fn eq(&self, other: &Unique<I>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<I: Eq + Id> Eq for Unique<I>

Source§

impl<I: Id> StructuralPartialEq for Unique<I>

Source§

impl<I: Id> Sync for Unique<I>

Auto Trait Implementations§

§

impl<I> Freeze for Unique<I>
where I: Freeze,

§

impl<I> RefUnwindSafe for Unique<I>
where I: RefUnwindSafe,

§

impl<I> Send for Unique<I>
where I: Send,

§

impl<I> Unpin for Unique<I>
where I: Unpin,

§

impl<I> UnwindSafe for Unique<I>
where I: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.