#[repr(transparent)]pub struct AsCopy<T: Copy>(pub T);
Expand description
Transparent wrapper for Copy
able types to support all traits (by copying).
// Simple struct which uses `Ipv4Addr` with the help of `AsCopy`.
// As an alternative it's possible to impl the ownable traits by hand (for own types, not `Ipv4Addr`).
#[derive(IntoOwned, ToBorrowed, ToOwned)]
struct MyMap<'a>(HashMap<AsCopy<Ipv4Addr>, Cow<'a, str>>);
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: T
Trait Implementations§
source§impl<T: Copy> BorrowMut<T> for AsCopy<T>
impl<T: Copy> BorrowMut<T> for AsCopy<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: Copy + Ord> Ord for AsCopy<T>
impl<T: Copy + Ord> Ord for AsCopy<T>
source§impl<T: Copy + PartialEq> PartialEq for AsCopy<T>
impl<T: Copy + PartialEq> PartialEq for AsCopy<T>
source§impl<T: Copy + PartialOrd> PartialOrd for AsCopy<T>
impl<T: Copy + PartialOrd> PartialOrd for AsCopy<T>
source§impl<T: Copy> ToBorrowed<'_> for AsCopy<T>
impl<T: Copy> ToBorrowed<'_> for AsCopy<T>
source§fn to_borrowed(&self) -> Self
fn to_borrowed(&self) -> Self
Copy the structure and reference the original values. Read more
impl<T: Copy + Eq> Eq for AsCopy<T>
Auto Trait Implementations§
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