Module objc2::mutability

source ·
Expand description

Marker types for class mutability.

Every class must indicate which kind of mutability its instances use:

  • Is the instance mutable or immutable?
  • Does it use interior mutability (mutable behind &self, like UnsafeCell)?
  • Does it access global statics in such a way that the type is only safe to use from the main thread?

The answer to these facts influence the final capabilities the type has, as encoded in the traits in this module.

Concretely, you set ClassType::Mutability to one of the types in this module to indicate the properties of class you’re dealing with (can be done inside extern_class! and declare_class!).

Note that precious little of Objective-C follows Rust’s usual shared xor unique ownership model, most often objects assume interior mutability.

SemVer

It is considered a major change to change the ClassType::Mutability of an object, though it can be done as a minor change in some cases to fix a bug.

Structs

Traits