#[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 Yokes:

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

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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Deserialize this value from the given Serde deserializer. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Clone the other C into a struct that may retain references into C.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.