-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Treating Foundation objects as rust references is hard. Currently this crate can be used to violate soundness rules within safe code, which could result in undefined behavior.
One problem right now comes from NSCopying
:
let mut string1 = NSString::from_str("Hello, world!");
let string2 = string1.copy();
let s1: &mut NSString = &mut string1;
let s2: &NSString = &string2;
println!("{:p}", s1);
println!("{:p}", s2);
This code results in an owned Id
and a ShareId
of the same object, allowing an &mut
reference to an address while a &
reference exists for the same address. This violates the aliasing requirements.
It may be the case that it's just too difficult to safely treat Objective-C objects as rust references and this crate is a failed experiment.
Metadata
Metadata
Assignees
Labels
No labels