pub unsafe trait NSCopying: Message {
    type Ownership: Ownership;
    type Output: Message;

    // Provided method
    fn copy(&self) -> Id<Self::Output, Self::Ownership> { ... }
}

Required Associated Types§

source

type Ownership: Ownership

Indicates whether the type is mutable or immutable.

This can be Owned if and only if copy creates a new instance, see the following example:

let x: Id<MyObject, _> = MyObject::new();
// This is valid only if `y` is a new instance. Otherwise `x` and `y`
// would be able to create aliasing mutable references!
let y: Id<MyObject, Owned> = x.copy();

Note that for the same reason, you should be careful when defining new methods on your object; e.g. immutable types like NSString don’t return Id<NSString, Owned>, because that would allow this trait to create an aliasing Id<NSString, Shared> (since sending the copy message (and others) does not create a new instance, but instead just retains the instance).

source

type Output: Message

The output type.

This is usually Self, but e.g. NSMutableString returns NSString. TODO: Verify???

Provided Methods§

source

fn copy(&self) -> Id<Self::Output, Self::Ownership>

Implementors§

source§

impl NSCopying for NSAttributedString

source§

impl NSCopying for NSData

source§

impl NSCopying for NSError

source§

impl NSCopying for NSException

source§

impl NSCopying for NSMutableAttributedString

source§

impl NSCopying for NSMutableData

source§

impl NSCopying for NSMutableString

source§

impl NSCopying for NSNumber

source§

impl NSCopying for NSString

source§

impl NSCopying for NSUUID

source§

impl NSCopying for NSValue

source§

impl<T: Message> NSCopying for NSArray<T, Shared>

This is implemented as a shallow copy.

As such, it is only possible when the array’s contents are Shared.

source§

impl<T: Message> NSCopying for NSMutableArray<T, Shared>

This is implemented as a shallow copy.

source§

impl<T: Message> NSCopying for NSMutableSet<T, Shared>

source§

impl<T: Message> NSCopying for NSSet<T, Shared>