👩💻 Join our community of thousands of amazing developers!
After posting a Rust translation of some k-nearest neighbour code, I got a few comments asking “how would you handle errors if you wanted to?”. This is the perfect chance to briefly demonstrate a few idioms. See my previous post for context and the original code; like with the code in that post, this code compiles with rustc 0.11.0-pre-nightly (e55f64f 2014-06-09 01:11:58 -0700) What type of error handling to use? The “canonical” way is to use type system, with types like Result<A, B>, which can...