#[repr(transparent)]pub struct Unit<T, Marker>(pub T, _);
Expand description
Add a marker to another type, eg Unit<Point3, LastPosition>
.
Unit
s try to be as transparent as possible: they deref to T
, and the various operators
forward to it.
Tuple Fields§
§0: T
Implementations§
source§impl<T, M> Unit<T, M>
impl<T, M> Unit<T, M>
source§impl<T> Unit<T, ()>
impl<T> Unit<T, ()>
pub const fn new<M>(t: T) -> Unit<T, M>
sourcepub const fn index<M>(t: T) -> Unit<T, [M; 0]>
pub const fn index<M>(t: T) -> Unit<T, [M; 0]>
Constructs an index. You can use this to prevent using an index on the wrong value.
See OfUnit::over
for a more pleasant API.
Example
let data1 = vec![0];
struct Marked;
let data2 = Unit::new::<Marked>(data1.clone());
assert_eq!(
data1[0],
data2[Unit::index::<Marked>(0usize)],
);
Trait Implementations§
source§impl<T, M> AddAssign<T> for Unit<T, M>where
T: AddAssign,
impl<T, M> AddAssign<T> for Unit<T, M>where T: AddAssign,
source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
Performs the
+=
operation. Read moresource§impl<T, M> AddAssign<Unit<T, M>> for Unit<T, M>where
T: AddAssign,
impl<T, M> AddAssign<Unit<T, M>> for Unit<T, M>where T: AddAssign,
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moresource§impl<T, M> BitAndAssign<T> for Unit<T, M>where
T: BitAndAssign,
impl<T, M> BitAndAssign<T> for Unit<T, M>where T: BitAndAssign,
source§fn bitand_assign(&mut self, rhs: T)
fn bitand_assign(&mut self, rhs: T)
Performs the
&=
operation. Read moresource§impl<T, M> BitAndAssign<Unit<T, M>> for Unit<T, M>where
T: BitAndAssign,
impl<T, M> BitAndAssign<Unit<T, M>> for Unit<T, M>where T: BitAndAssign,
source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
Performs the
&=
operation. Read moresource§impl<T, M> BitOrAssign<T> for Unit<T, M>where
T: BitOrAssign,
impl<T, M> BitOrAssign<T> for Unit<T, M>where T: BitOrAssign,
source§fn bitor_assign(&mut self, rhs: T)
fn bitor_assign(&mut self, rhs: T)
Performs the
|=
operation. Read moresource§impl<T, M> BitOrAssign<Unit<T, M>> for Unit<T, M>where
T: BitOrAssign,
impl<T, M> BitOrAssign<Unit<T, M>> for Unit<T, M>where T: BitOrAssign,
source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
Performs the
|=
operation. Read moresource§impl<T, M> BitXorAssign<T> for Unit<T, M>where
T: BitXorAssign,
impl<T, M> BitXorAssign<T> for Unit<T, M>where T: BitXorAssign,
source§fn bitxor_assign(&mut self, rhs: T)
fn bitxor_assign(&mut self, rhs: T)
Performs the
^=
operation. Read moresource§impl<T, M> BitXorAssign<Unit<T, M>> for Unit<T, M>where
T: BitXorAssign,
impl<T, M> BitXorAssign<Unit<T, M>> for Unit<T, M>where T: BitXorAssign,
source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
Performs the
^=
operation. Read moresource§impl<T, M> DivAssign<T> for Unit<T, M>where
T: DivAssign,
impl<T, M> DivAssign<T> for Unit<T, M>where T: DivAssign,
source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Performs the
/=
operation. Read moresource§impl<T, M> DivAssign<Unit<T, M>> for Unit<T, M>where
T: DivAssign,
impl<T, M> DivAssign<Unit<T, M>> for Unit<T, M>where T: DivAssign,
source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the
/=
operation. Read moresource§impl<T, M, I> IndexMut<Unit<I, [M; 0]>> for Unit<T, M>where
T: IndexMut<usize>,
I: IntoIndex,
impl<T, M, I> IndexMut<Unit<I, [M; 0]>> for Unit<T, M>where T: IndexMut<usize>, I: IntoIndex,
source§impl<T, M> MulAssign<T> for Unit<T, M>where
T: MulAssign,
impl<T, M> MulAssign<T> for Unit<T, M>where T: MulAssign,
source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Performs the
*=
operation. Read moresource§impl<T, M> MulAssign<Unit<T, M>> for Unit<T, M>where
T: MulAssign,
impl<T, M> MulAssign<Unit<T, M>> for Unit<T, M>where T: MulAssign,
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*=
operation. Read moresource§impl<T, M> PartialEq<Unit<T, M>> for Unit<T, M>where
T: PartialEq,
impl<T, M> PartialEq<Unit<T, M>> for Unit<T, M>where T: PartialEq,
source§impl<T, M> PartialOrd<T> for Unit<T, M>where
T: PartialOrd,
impl<T, M> PartialOrd<T> for Unit<T, M>where T: PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl<T, M> PartialOrd<Unit<T, M>> for Unit<T, M>where
T: PartialOrd,
impl<T, M> PartialOrd<Unit<T, M>> for Unit<T, M>where T: PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl<T, M> RemAssign<T> for Unit<T, M>where
T: RemAssign,
impl<T, M> RemAssign<T> for Unit<T, M>where T: RemAssign,
source§fn rem_assign(&mut self, rhs: T)
fn rem_assign(&mut self, rhs: T)
Performs the
%=
operation. Read moresource§impl<T, M> RemAssign<Unit<T, M>> for Unit<T, M>where
T: RemAssign,
impl<T, M> RemAssign<Unit<T, M>> for Unit<T, M>where T: RemAssign,
source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
Performs the
%=
operation. Read moresource§impl<T, M> ShlAssign<T> for Unit<T, M>where
T: ShlAssign,
impl<T, M> ShlAssign<T> for Unit<T, M>where T: ShlAssign,
source§fn shl_assign(&mut self, rhs: T)
fn shl_assign(&mut self, rhs: T)
Performs the
<<=
operation. Read moresource§impl<T, M> ShlAssign<Unit<T, M>> for Unit<T, M>where
T: ShlAssign,
impl<T, M> ShlAssign<Unit<T, M>> for Unit<T, M>where T: ShlAssign,
source§fn shl_assign(&mut self, rhs: Self)
fn shl_assign(&mut self, rhs: Self)
Performs the
<<=
operation. Read moresource§impl<T, M> ShrAssign<T> for Unit<T, M>where
T: ShrAssign,
impl<T, M> ShrAssign<T> for Unit<T, M>where T: ShrAssign,
source§fn shr_assign(&mut self, rhs: T)
fn shr_assign(&mut self, rhs: T)
Performs the
>>=
operation. Read moresource§impl<T, M> ShrAssign<Unit<T, M>> for Unit<T, M>where
T: ShrAssign,
impl<T, M> ShrAssign<Unit<T, M>> for Unit<T, M>where T: ShrAssign,
source§fn shr_assign(&mut self, rhs: Self)
fn shr_assign(&mut self, rhs: Self)
Performs the
>>=
operation. Read moresource§impl<T, M> SubAssign<T> for Unit<T, M>where
T: SubAssign,
impl<T, M> SubAssign<T> for Unit<T, M>where T: SubAssign,
source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
Performs the
-=
operation. Read moresource§impl<T, M> SubAssign<Unit<T, M>> for Unit<T, M>where
T: SubAssign,
impl<T, M> SubAssign<Unit<T, M>> for Unit<T, M>where T: SubAssign,
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read more