Struct yoke::trait_hack::YokeTraitHack
source · [−]#[repr(transparent)]pub struct YokeTraitHack<T>(pub T);
Expand description
A wrapper around a type T
, forwarding trait calls down to the inner type.
YokeTraitHack
supports Clone
, PartialEq
, Eq
, and serde::Deserialize
out of
the box. Other traits can be implemented by the caller.
For more information, see the module-level documentation.
Example
Using YokeTraitHack
as a type bound in a function comparing two Yoke
s:
use yoke::trait_hack::YokeTraitHack;
use yoke::*;
fn compare_yokes<Y, C1, C2>(y1: Yoke<Y, C1>, y2: Yoke<Y, C2>) -> bool
where
Y: for<'a> Yokeable<'a>,
for<'a> YokeTraitHack<<Y as Yokeable<'a>>::Output>: PartialEq,
{
YokeTraitHack(y1.get()).into_ref() == YokeTraitHack(y2.get()).into_ref()
}
Tuple Fields
0: T
Implementations
sourceimpl<'a, T> YokeTraitHack<&'a T>
impl<'a, T> YokeTraitHack<&'a T>
sourcepub fn into_ref(self) -> &'a YokeTraitHack<T>
pub fn into_ref(self) -> &'a YokeTraitHack<T>
Converts from YokeTraitHack<&T>
to &YokeTraitHack<T>
.
This is safe because YokeTraitHack
is repr(transparent)
.
This method is required to implement Clone
on Yoke
.
Trait Implementations
sourceimpl<T: Clone> Clone for YokeTraitHack<T>
impl<T: Clone> Clone for YokeTraitHack<T>
sourcefn clone(&self) -> YokeTraitHack<T>
fn clone(&self) -> YokeTraitHack<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'de, T> Deserialize<'de> for YokeTraitHack<T> where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for YokeTraitHack<T> where
T: Deserialize<'de>,
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T: PartialEq> PartialEq<YokeTraitHack<T>> for YokeTraitHack<T>
impl<T: PartialEq> PartialEq<YokeTraitHack<T>> for YokeTraitHack<T>
sourcefn eq(&self, other: &YokeTraitHack<T>) -> bool
fn eq(&self, other: &YokeTraitHack<T>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &YokeTraitHack<T>) -> bool
fn ne(&self, other: &YokeTraitHack<T>) -> bool
This method tests for !=
.
sourceimpl<'zf, C: ?Sized, T> ZeroFrom<'zf, C> for YokeTraitHack<T> where
T: ZeroFrom<'zf, C>,
impl<'zf, C: ?Sized, T> ZeroFrom<'zf, C> for YokeTraitHack<T> where
T: ZeroFrom<'zf, C>,
impl<T: Eq> Eq for YokeTraitHack<T>
impl<T> StructuralEq for YokeTraitHack<T>
impl<T> StructuralPartialEq for YokeTraitHack<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for YokeTraitHack<T> where
T: RefUnwindSafe,
impl<T> Send for YokeTraitHack<T> where
T: Send,
impl<T> Sync for YokeTraitHack<T> where
T: Sync,
impl<T> Unpin for YokeTraitHack<T> where
T: Unpin,
impl<T> UnwindSafe for YokeTraitHack<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more