pub trait Tee {
// Required method
fn tee<const N: usize>(self) -> <Self as TeeInternal<N>>::Output
where Self: TeeInternal<N>;
}Required Methods§
Sourcefn tee<const N: usize>(self) -> <Self as TeeInternal<N>>::Outputwhere
Self: TeeInternal<N>,
fn tee<const N: usize>(self) -> <Self as TeeInternal<N>>::Outputwhere
Self: TeeInternal<N>,
Extension method to add tee() method to all T: Clone.
This can’t be done directly as part of TeeInternal because it makes
specifying the const param at the tee() invocation site
cumbersome: TeeInternal::<N>::tee(&obj) as opposed to
obj.tee::<N>(). The constraint Self: TeeInternal<N> collapses
the potential impl matches to exactly 1, which makes the call to
tee_internal() unambiguous. This constraint is also allowed to
contain the generic parameter N because it is specified as a
constraint to the method (as opposed to a constraint on the trait).
I’m honestly quite surprised this works …
§Examples
let x = "test".tee::<2>();
assert_eq!(x.0, x.1);
assert_eq!(x.0, "test");Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.