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.
miniblog.
Related Posts
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.)
I find mypy very helpful for refactoring Python codebases. It sometimes finds bugs before I run my refactored code, but a large percentage of the time it's just helpfully pointing out where I have the wrong number of args.
Pareto principle strikes again.