#[repr(transparent)]pub struct AsClone<T: Clone>(pub T);Expand description
Transparent wrapper for Cloneable types to support all traits (by cloning).
#[derive(Clone)]
struct NotIntoOwned;
fn requires_into_owned<O: IntoOwned>(o: O) {
// do stuff
}
// `AsClone<NotIntoOwned>` implements `IntoOwned` through `Clone`
requires_into_owned(AsClone(NotIntoOwned));All trait impls work on the inner value as if there is no layer in between
(e.g. Display does not add a AsClone to the output).
Tuple Fields§
§0: TTrait Implementations§
Source§impl<T: Clone> BorrowMut<T> for AsClone<T>
impl<T: Clone> BorrowMut<T> for AsClone<T>
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T: Clone + Ord> Ord for AsClone<T>
impl<T: Clone + Ord> Ord for AsClone<T>
Source§impl<T: Clone + PartialOrd> PartialOrd for AsClone<T>
impl<T: Clone + PartialOrd> PartialOrd for AsClone<T>
Source§impl<T: Clone> ToBorrowed<'_> for AsClone<T>
impl<T: Clone> ToBorrowed<'_> for AsClone<T>
Source§fn to_borrowed(&self) -> Self
fn to_borrowed(&self) -> Self
Copy the structure and reference the original values. Read more
impl<T: Clone + Eq> Eq for AsClone<T>
Auto Trait Implementations§
impl<T> Freeze for AsClone<T>where
T: Freeze,
impl<T> RefUnwindSafe for AsClone<T>where
T: RefUnwindSafe,
impl<T> Send for AsClone<T>where
T: Send,
impl<T> Sync for AsClone<T>where
T: Sync,
impl<T> Unpin for AsClone<T>where
T: Unpin,
impl<T> UnwindSafe for AsClone<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more