This bothers me about Rust.
There's too much "unsafe" code in libraries.
I like how with Rust you use one or two unsafe blocks and everyone loses their mind. But in C/C++ you spatter your code with undefined behavior and nobody bats an eye. I get Rust is _safe_ so violating this contract is in a way self defeating. But even with a handful of unsafe blocks you are miles ahead of other guarantees C/C++ give you. Lastly unlike C/C++ Rust makes you call out
I'm doing dangerous stuff here! The language is unable to express some essential concepts.
Not really. The same code the parent poster highlighted [1] is undefined behavior in C/C++ (with standard types). So really no language has the ability to express those concepts. Your doing pointer casts and possibly unaligned dereferences at the same time. This has zero consistency between CPU vendors.
[1] https://docs.rs/crate/seahash/2.0.0/source/src/buffer.rs
Known areas of trouble include partial initialization of an array, needed to implement growable collections
You mean Vector? C Doesn't have grow-able array's. They have
re-alloc but Rust's Vector does that.
https://doc.rust-lang.org/std/vec/struct.Vec.html
and single ownership doubly linked lists.
They already did, and it is in the standard library.
https://doc.rust-lang.org/std/collections/struct.LinkedList....
If Rust let you access a slice of bytes as an slice of ints, alignment and length permitting,
the code above could be much more straightforward.
I mean C/C++ do, but without stdint.h you do this at your own peril. Even then you'll likely use Unions which are undefined behavior.
What would happen on a 32-bit machine if someone allocated a buffer bigger than 2GB? Exploitable?
You can state this about C/C++ also.