pub struct TypedId<I, T>(pub I, _);Expand description
A generic type-checked wrapper around a generic identifier type
Tuple Fields§
§0: IImplementations§
Source§impl<I, T> TypedId<I, T>
impl<I, T> TypedId<I, T>
Sourcepub fn convert<B: From<I>>(self) -> B
pub fn convert<B: From<I>>(self) -> B
The method explicitly converts between typed ids.
use typed_id::TypedId;
let a_id: TypedId<u32, A> = 42.into();
let b_id: TypedId<u32, B> = a_id.convert();Note, From can not be implemented here. We can’t specify that two generic types, A and
B, are distinct. If we try, this fails to compile.
ⓘ
impl<I, A, B> From<TypedId<I, A>> for TypedId<I, B> {
fn from(other: TypedId<I, A>) -> TypedId<I, B> {
other.0.into()
}
}Trait Implementations§
Source§impl<I: Ord, T> Ord for TypedId<I, T>
impl<I: Ord, T> Ord for TypedId<I, T>
Source§impl<I: PartialOrd, T> PartialOrd for TypedId<I, T>
impl<I: PartialOrd, T> PartialOrd for TypedId<I, T>
impl<I: Copy, T> Copy for TypedId<I, T>
impl<I: Eq, T> Eq for TypedId<I, T>
Auto Trait Implementations§
impl<I, T> Freeze for TypedId<I, T>where
I: Freeze,
impl<I, T> RefUnwindSafe for TypedId<I, T>where
I: RefUnwindSafe,
T: RefUnwindSafe,
impl<I, T> Send for TypedId<I, T>
impl<I, T> Sync for TypedId<I, T>
impl<I, T> Unpin for TypedId<I, T>
impl<I, T> UnwindSafe for TypedId<I, T>where
I: UnwindSafe,
T: UnwindSafe,
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