this post was submitted on 15 Mar 2025
22 points (100.0% liked)
Rust
6609 readers
42 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Doubly linked list is one of std's collections. And safety in Rust is built on top of unsafely, because there is no way around that.
Did you try to actually look up literally anything before asking?! Because simply checking out
std::collections
docs would have given you some answers.I don't see anything in the std::collections doc relevant to this question. Yes I knew about the presence of doubly linked lists in that library. Obviously you could implement the DOM structure unsafely with C-style pointers but then what are you getting from using Rust instead of C? So I hoped to hear how to do it safely, maybe using a library object as a building block. But, I don't think the stuff in std::collections suffice for the purpose.
Rust safety isn't necessarily built on unsafety, though apparently it is in the case of doubly linked lists. I think singly linked lists can be made safely in Rust, similar to using C++ std::unique_ptr. It's possible, though very complicated, to eliminate all the unsafety everywhere. Rust doesn't attempt this, but (for example) ATS does (ats-lang.org).
Anyway your scolding is unhelpful. If you've got a usable and clear answer to my question I'd be happy to try to digest it. Otherwise I don't see any point in continuing to respond.