DEV Community

Discussion on: Letting the compiler tell you what to do - an example using Rust

Collapse
 
jeikabu profile image
jeikabu

Having used a slew of other languages, have to say I'm often impressed with the Rust compiler. It's invaluable navigating some of the stickier areas of the language. When I can't make sense of the errors the first course of action is simplifying the code (e.g. breaking down into more statements, reducing indirection, etc.) to get sensible feedback.

Unrelated but in the same vein was something I originally read in an F# article of "using the types to guide you" when looking for solutions. Can't find it now but it was essentially talking about if you need A -> B[] then function prototypes like F(A) -> B and B -> B[] get you there. It's essential in languages with more extreme type inference than Rust, but the general concept is helpful.