Struct cfx_storage::utils::guarded_value::NonCopy
source · pub struct NonCopy<T: ?Sized>(pub T);
Expand description
To prevent automatic copy from leaking guarded value. Please always wrap the value with NonCopy if the value is Copy otherwise it’s so easy to accidentally copy without notice, e.g. in matching arms, if let clauses.
Tuple Fields§
§0: T
Trait Implementations§
source§impl<T: ?Sized> Deref for NonCopy<T>
impl<T: ?Sized> Deref for NonCopy<T>
Ideally, we should also deref to the next level like above. However, there can be GuardedValue like Option<&’a Target>, for which we can’t really do anything more, unless we introduce concept like lifetime coercion classes.
The goal for all implementations here is to make it hard enough to do something wrong by accident, but still keep it simple.
Auto Trait Implementations§
impl<T: ?Sized> RefUnwindSafe for NonCopy<T>where
T: RefUnwindSafe,
impl<T: ?Sized> Send for NonCopy<T>where
T: Send,
impl<T: ?Sized> Sync for NonCopy<T>where
T: Sync,
impl<T: ?Sized> Unpin for NonCopy<T>where
T: Unpin,
impl<T: ?Sized> UnwindSafe for NonCopy<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