4 ms·
An accurate summary. I was reflecting exactly your cons when I left gaps in what I said Rust was good for. Con (1) (Existing examples / training) is a legacy l
by gridspy 4y ago
An accurate summary. I was reflecting exactly your cons when I left gaps in what I said Rust was good for.
Con (1) (Existing examples / training) is a legacy language strength in general, C++ is going to lead in this for a long time.
Con (2) (Low level data structures) I 100% agree. A toy example of a datastructure in C++ is going to be really easy to express but also dangerous to use.
I think you'd really enjoy this chapter of the Rust Docs on making your own Vec
https://doc.rust-lang.org/nomicon/vec/vec.html https://doc.rust-lang.org/nomicon/vec/vec.html
And you are correct (Con 2 again), it IS an advanced practice. The result of making a data-stucture the rust way is a bulletproof class anyone can use, rather than a C++ foot-gun so it's worth the effort (but less so for learning).
You might find you can make your whole module unsafe and write a very similar data-structure in rust to your C++ solution (pointers and all) and it would compile and run fine.
- lumost 4y agoThe big thing to know about rust datastructures is that you need to use unsafe to implement anything cyclic. There is nothing wrong with using unsafe for a few lines of code - just review carefully.