Basically I have a question related to the topic of implicitly converting all the Err() into my error type.
Let's assume I am creating a crypto crate. As I understand it cryptographers are really paranoid about leaking internals, therefore I just have a struct CryptoError; which is the error type of the Result in this crate. Obviously I really don't care about implementing each implicit conversion manually, so the straight forward way would be:
I suppose, long-term / in the future a custom Result-like type (or in this case it’s actually more of an Option-like type) together with a Try implementation might constitute a nice solution. Not until the trait is stabilized, of course. See this playground for example.
Anyhow implements conversion from types E: std::error::Error, but anyhow::Error does not implement the std::error::Error trait itself. This way, the overlap with the blanket From<T> for T implementation is avoided.
The version where I implement each conversion individually seems like the cleanest one, but I really fear that it is too much work and it will make the life difficult for everybody working on the project
I really like the flexibility of the custom Try implementation. But it also feels wrong, because what I mean to express is a Result but I am using a different type.
Not implementing Error for my type would probably work for me. This is not a public project, so I do not have to worry about the consumer of the library.
Your analogy to an Option gave me an idea. Similarly to .ok() I could just implement a function like that: