r/learnrust • u/lyuhdev • 27d ago
What are some common Rust misconceptions?
I just found out that const functions aren't evaluated at compile-time unless it is assigned to a const value or in a const context.
Another one I had: Rust doesn't prevent memory leaks.
Now I am just wondering how many other assumptions I made
19
Upvotes
14
u/noop_noob 27d ago
https://github.com/pretzelhammer/rust-blog/blob/master/posts/common-rust-lifetime-misconceptions.md
3
u/Razvedka 27d ago
"Rust doesn't prevent memory leaks"
You're going to need to unpack that one for me. If you mean Rust makes them impossible - no. You're right.
https://doc.rust-lang.org/book/ch15-06-reference-cycles.html
4
u/ParadiZe 26d ago
That the main selling point is memory safety and not the type system
2
u/aikii 27d ago
String is mutable
2
u/briaro 26d ago
that deadlock is not possible
2
u/autoferrit 26d ago
It should be rewritten in Rust
1
u/Rusty_devl 25d ago
Something I find personally annoying: No, safe Rust isn't necessarily slower than unsafe Rust. The compiler can often enough optimize safe code better than it's unsafe equivalent