Struct objc2::mutability::Mutable
source · pub struct Mutable { /* private fields */ }
Expand description
Marker type for mutable classes.
Note that mutable objects are often both Send
and Sync
, though
such implementations must be provided manually (and are usually only safe
if all mutation happens behind &mut self
).
Functionality that is provided with this:
IsAllocableAnyThread
->ClassType::alloc
.IsAllowedMutable
.IsMutable
->impl DerefMut for Retained
.- You are allowed to hand out pointers / references to an instance’s internal data, since you know such data will never be mutated without the borrowchecker catching it.
§Safety notice
- (Safe) methods that mutate the object (without synchronization) are
required to use
&mut self
. - The
retain
selector is not generally safe to use on classesT
that specify this, sinceRetained<T>
allows having&mut T
references, which Rust assume are unique. - As a special case of that,
-[NSCopying copy]
and-[NSMutableCopying mutableCopy]
, if implemented, must return a new instance (e.g. cannot be implemented by justretain
-ing the instance).
Trait Implementations§
source§impl Ord for Mutable
impl Ord for Mutable
source§impl PartialEq for Mutable
impl PartialEq for Mutable
source§impl PartialOrd for Mutable
impl PartialOrd for Mutable
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Mutable
impl Eq for Mutable
impl Mutability for Mutable
impl StructuralPartialEq for Mutable
Auto Trait Implementations§
impl Freeze for Mutable
impl RefUnwindSafe for Mutable
impl Send for Mutable
impl Sync for Mutable
impl Unpin for Mutable
impl UnwindSafe for Mutable
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