Rust is doing this correctly. It’s better to model things as they are rather than requiring a bunch of implicit knowledge.
The simplicity of C is dangerously misleading.
Learn Rust the Dangerous Way
is a series of articles putting Rust features in context for low-level C programmers — the sort of people who work on firmware, game engines, OS kernels, and the like.
… was a delightful Saturday morning read. Link in the reply.
In Rust when you see
let y = x.clone();
You don’t know if it’s a cheap reference count increment or an expensive allocation and memcopy. You can do this instead:
let y = Arc::clone(x);
And enforce it with a clippy lint:
#![deny(clippy::clone_on_ref_ptr)]
Reading large csv files in parallel chunks is tricky because you can’t be sure a line end isn’t in a quoted field. But I found a paper showing how to make a good guess that works most of the time!
I think I’m now at a point where I’m more productive in Rust than TypeScript or PHP because I spend almost no time debugging. An expressive type system and pattern matching is a game changer.
If it compiles it works.
I know I’m a bit in the Rust bubble but there really does seem to be a lot of new and impressive software being built in Rust? It seems to be accelerating.
Rust lifetime misconceptions #5: if it compiles then my lifetime annotations are correct
The inferred lifetime for the returned Option<&u8> is the lifetime of &mut self but semantically we want it to be the lifetime of remainder. So it needs to be annotated.
This clickable diagram from Effective Rust showing all the transforms for Option and Rust is an absolute masterpiece: docs.google.com/drawings/d/1EO…
The only other thing you need to know is when to use as_ref.
The arrival of an Effective book for Rust seems like a coming of age thing. Rust has matured to the point where best practice guidelines are established.
I’m a fan because it reduces the cognitive load of making things go brrr.
lurklurk.org/effective-rust/
I've been implementing a simple binary tree. This has really driven home for me that collections need to implement three different iterators: one for references, one for mutable references and one that consumes the collection - which is the one shown here for my binary tree.
Rust has a fear problem.
I semi-seriously implied to someone that they could re-write their Typescript lambdas in Rust and save a bunch of money.
They were terrified that it would be impossible to find people capable of doing it.