3 ms·
Is this actually safe? What happens if you have ownership, then you can mutate the struct Foo like this: foo.s1 = "World" Which destroys the original hea
by rrobukef 10y ago
Is this actually safe?
What happens if you have ownership, then you can mutate the struct Foo like this:
foo.s1 = "World"
Which destroys the original heap data. Then s2 is a dangling reference. Since references cannot implement a drop method, you need a wrapping datastructure WITH reference counting, like you said.
- steveklabnik 10y ago> then you can mutate the struct Foo like this: You couldn't because it'd be immutably borrowed.