▲ | skywal_l 4 days ago | |||||||||||||||||||||||||||||||||||||||||||
I don't understand your comment. `drop` takes a *mutable* reference. But by default, references in Rust are immutable. | ||||||||||||||||||||||||||||||||||||||||||||
▲ | littlestymaar 4 days ago | parent | next [-] | |||||||||||||||||||||||||||||||||||||||||||
shared references are immutable in Rust, mut references and shared references are both references. | ||||||||||||||||||||||||||||||||||||||||||||
▲ | Ygg2 4 days ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||
Kibwen is saying that there was an idea to have `fn drop(&mut x)` from Drop trait become `fn drop_own(&own x)`. Then `&own` would do mutation and drop the owner of the reference. A regular &mut reference shouldn't do that outside of `drop(&mut x)`. | ||||||||||||||||||||||||||||||||||||||||||||
▲ | codedokode 4 days ago | parent | prev [-] | |||||||||||||||||||||||||||||||||||||||||||
Drop takes an object itself ("owned reference"), as I remember. Mutable ref allows reading/writing but not destroying or passing the ownership. Owner = can read/write/destroy Mutable ref = can read/write Immutable ref = can only read, guarantered not to change | ||||||||||||||||||||||||||||||||||||||||||||
|