When I wrote my first Rust program, I got the advice "just clone everything until v1 compiles". I think this OK advice, but I think a better rule of thumb is "used owned types as much as possible".
I spent a ton of time returning &str or &[T] and fighting the borrow checker.
miniblog.
Related Posts
I'm having fun writing a simple type checker, but I'm learning firsthand why syntax-directed checking doesn't work. It prevents inference.
My checker catches real bugs, but it can't handle cases like this:
[1, 2].map(fun(x) { x + 1; })
I think I need bidirectional checking.
Noodling with an interpreter for a statically typed language with reified types (e.g. a list knows what type it contains).
Currently I have a single representation of types in both the runtime and the type checker. I think that's a good thing?
I've written a very small, very bad, type checker for my toy programming language. Within three days, it found a bug in a program I was writing!