Skip to content

mem::swap doesn't work with Objects #6

Open
@SSheldon

Description

@SSheldon

For example, the following code:

let mut a: Id<NSString> = INSString::from_str("a");
let mut b: Id<NSString> = INSString::from_str("b");
println!("{} {}", a, b);

mem::swap(a.deref_mut(), b.deref_mut());
println!("{} {}", a, b);

Expected output:

a b
b a

Actual output:

a b
a b

We cannot have the expected output happen, because an NSObject's memory address cannot change after it has been constructed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions