@rustlang peeps: I want to write a blanket trait impl of From<T> for Type where T implements Trait, and Type also implements Trait, but where T and Type are not the same type. Is there a way in trait bounds to specify effectively "T: !Type" to avoid conflict w/ `From<T> for T`?
Alternatively, you can implement a `NotType` trait for all types you ever encounter that aren't `Type` and then add a `NotType` constraint to the impl. However, negative trait bounds (these fake ones or real ones) are really questionable in the first place.
-
-
Ok so the use case is Fail and my own Error type, which implements Fail itself. I want to wrap all Fails with my own Error with an inner context of the wrapped error. What I did instead is create a helper function.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
I really wanted to write `expr?` or `future.from_err()` instead of `.map_err(MyError::helper_function)`. stupid, i know. turned into a exercise.
-
It's not stupid to want to do that. My `NotType` suggestion often works pretty well for that kind of use case because there are usually not many different kinds of errors you need to wrap, so manually implementing one trait for each isn't the end of the world.
End of conversation
New conversation -
-
-
turns out i like the explicitness better, so doubly stupid. i’m only doing it with errors i didn’t want to explicitly tag with a specific ErrorKind; it’s tagged with a generic ErrorKind::Unknown.
-
Yeah, often this automatic wrapping of errors doesn't make much sense, especially because it often exposes a detail of the implementation in the (public) interface of your own API.
-
True. I am going to actually create a specific AWS errorkind and handle them directly. Thanks for the help.
-
Will also keep the dual trait idea in mind for a suitable use case. I was about to go down that route (impl a new owned trait for each error type, and bind on that trait) until I decided against.
End of conversation
New conversation -
-
-
Area of use is Rusoto where every API has a unique error type.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.