As for the second example I don't think it's a language issue but more a programmer one, how Rust would have saved you in that case, anyone could have returned 0 for the price instead of a proper type. Using Rust doesn't magically turn programmer into good ones. You still have to know how to properly design your code and best use the language and its features.
I'm often reading code in various language and I'm baffled at what a giant lib.rs looks like from someone that never really used Rust.