Refactored some unsafe FFI code to be idiomatic Rust today, and valgrind approves of everything on the first run. I'm impressed!
miniblog.
Related Posts
I refactored some Rust string splitting logic:
old: &[&str] -> Vec<String>
new: &[&str] -> Vec<&str>
It's a little faster, but it's an interesting type signature. You can figure out more of how the new one works! It must be slicing into the input string.
One cute property of the typescript/javascript relationship is that you can toggle whether (and when) you want static types.
At ~500 LOC I realised I had an error handler I'd refactored but missed an argument at a call site. Time to try some typescript!
Typescript has an interesting approach to type checking: it will emit JS even if the code isn't well-typed! https://basarat.gitbooks.io/typescript/docs/why-typescript.html
(This is a nice property of gradual typing: you can run unit tests on refactored code even when some code still uses the old API.)