Yes, a `Box<dyn Error>` is about the most rudimentary way of returning an arbitrary error, but it’s better than a panic or a sentinel value.
In that crate the &*msg.interface().unwrap() magically become an &str !
For example, the standard library `String` type dereferences to `str` which you can then re-reference to `&str`.
ameliaquining awnsered my question and you modulated my opinion, that pattern is can be idiomatic when the principle of minimal surprises is respected.
The Deref trait is designed for the implementation of custom pointer types. The intention is that it will take a pointer-to-T to a T, not convert between different types. It is a shame that this isn’t (probably cannot be) enforced by the trait definition.
Rust tries to strike a careful balance between explicit and implicit mechanisms, favouring explicit conversions between types. Automatic dereferencing in the dot operator is a case where the ergonomics strongly favour an implicit mechanism, but the intention is that this is limited to degrees of indirection, not conversion between arbitrary types.But I must admit that Cargo and clippy were nice and lifetime are easier to understand than when using std::move in c++ is required vs when it's implicit.
But really what made me abandon learning Rust is Nim. My first Nim program I made a small maze game in about 200 lines.
Also the fact that I now mostly program recreationally since I pivoted from software development to infrastructure ( my title is system analyst) at a research University (absolute job security is really nice). Software development at that institution was getting to political to my taste and I like to play with nice hardware!
From what I understand from the article, returning a dyn Error in a Result appears to be about as useful as throwing a new Exception("something bad happened") in java. I am sure it gets better in part two "Structured Rust errors" but this guide on error handling doesn't increase my motivation to give Rust another chance.