3 ms·
There is value in having unsafe parts of a program clearly annotated (not just with comments). It is similar to how in some languages you annotate pure function
by mejutoco 4y ago
There is value in having unsafe parts of a program clearly annotated (not just with comments). It is similar to how in some languages you annotate pure functions and they do not compile unless they are pure.
- llllllllllll9 4y agobe careful and do your research. anytime you need to implement anything that shares references (just about any data structure worth its weight in implementation time) you need to use Rc<> and friends. i am not talking about https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html. fine, this escape hatch is needed. i am referring to https://doc.rust-lang.org/book/ch15-06-reference-cycles.html https://doc.rust-lang.org/book/ch15-06-reference-cycles.html.
- mejutoco 4y agoAh, I see now. That makes sense. I stand corrected.
- pornel 4y agoIt's not anytime. It's limited to recursive types with interior mutability. These two conditions are specific to mutable graphs, not just any shared ownership. There are plenty of uses of Rc that cannot possibly cause a cycle.