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