[−][src]Struct inert::Inert
A wrapper for neutralized values.
If T
is Neutralize
, then it can be safely neutralized from an
immutable reference. Almost everything implements Neutralize
but
RefCell<T>
(and similar types).
If T
is NeutralizeMut
, then it can be safely neutralized from a mutable
reference. Almost everything implements NeutralizeMut
but Rc<RefCell<T>>
and &'a RefCell<T>
(and similar types).
If T
is NeutralizeUnsafe
, this type derefs to T::Output
,
with no safe way to reach out for the T
value itself, which is why
it is sound for Inert<T>
to be Sync
.
Methods
impl<T> Inert<T> where
T: ?Sized,
[src]
T: ?Sized,
pub fn new(value: &T) -> &Self where
T: Neutralize,
[src]
T: Neutralize,
Creates a new Inert<T>
from a reference.
pub fn new_mut(value: &mut T) -> &Self where
T: NeutralizeMut,
[src]
T: NeutralizeMut,
Creates a new Inert<T>
from a mutable reference.
pub unsafe fn new_unchecked(value: &T) -> &Self
[src]
Unsafely creates a new Inert<T>
from a reference.
Safety
The user must swear on the holy baguette that they won't do anything
with the &T
as long as any thread is still doing things with the
&Inert<T>
, either directly or through other neutralized values
reached through the inner &T::Output
value, lest they provoke
undefined behaviour, or worse, spoil their entire wheat harvest.
pub fn get_ref(this: &Self) -> &T where
T: Sync,
[src]
T: Sync,
Returns a reference to the inner T
.
pub unsafe fn get_ref_unchecked(this: &Self) -> &T
[src]
Unsafely returns a reference to the inner T
.
Safety
Undefined behaviour is possible if T
is not Sync
.
Trait Implementations
impl<T: ?Sized> PartialOrd<Inert<T>> for Inert<T> where
T: NeutralizeUnsafe,
T::Output: PartialOrd,
[src]
T: NeutralizeUnsafe,
T::Output: PartialOrd,
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T: ?Sized> AsRef<<T as NeutralizeUnsafe>::Output> for Inert<T> where
T: NeutralizeUnsafe,
[src]
T: NeutralizeUnsafe,
impl<T: ?Sized> PartialEq<Inert<T>> for Inert<T> where
T: NeutralizeUnsafe,
T::Output: PartialEq,
[src]
T: NeutralizeUnsafe,
T::Output: PartialEq,
fn eq(&self, other: &Self) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T> Sync for Inert<T> where
T: ?Sized,
[src]
T: ?Sized,
impl<T: ?Sized> Ord for Inert<T> where
T: NeutralizeUnsafe,
T::Output: Ord,
[src]
T: NeutralizeUnsafe,
T::Output: Ord,
fn cmp(&self, other: &Self) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl<T: ?Sized> Eq for Inert<T> where
T: NeutralizeUnsafe,
T::Output: Eq,
[src]
T: NeutralizeUnsafe,
T::Output: Eq,
impl<T: ?Sized> Display for Inert<T> where
T: NeutralizeUnsafe,
T::Output: Display,
[src]
T: NeutralizeUnsafe,
T::Output: Display,
impl<T: ?Sized> Debug for Inert<T> where
T: NeutralizeUnsafe,
T::Output: Debug,
[src]
T: NeutralizeUnsafe,
T::Output: Debug,
impl<T: ?Sized> Deref for Inert<T> where
T: NeutralizeUnsafe,
[src]
T: NeutralizeUnsafe,
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
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>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
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>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,