top | item 41370145

(no title)

BonusPlay | 1 year ago

I'm not a rust expert by any means, but I believe there's a problem with lifetimes. There are many ways to implement double-linked lists (think C++ smart pointers), but when you try to squeeze performance and use references, then it's a fight against borrow checker, which ends with the need to use unsafe rust.

smarter sources: https://rust-unofficial.github.io/too-many-lists/ https://softsilverwind.github.io/rust/2019/01/11/Rust-Linked...

discuss

order

oneshtein|1 year ago

Borrow checker is just a checker, which ensures that programmer doesn't write obviously wrong programs. It's obviously wrong to create cyclic references, even in a language with garbage collector, such as JavaScript. Why you need to fight with checker?

kbolino|1 year ago

Regarding the borrow checker, what you say is not correct. The borrow checker's rules are stricter than absolutely necessary. It is designed to reject all invalid programs, but it also rejects some valid programs.

__s|1 year ago

garbage collectors detect cycles. you may be thinking of reference counting. CPython includes a gc for cycle detection

LudwigNagasena|1 year ago

Why would it be obviously wrong?