@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.
4 replies 0 retweets 0 likes -
Replying to @BRIAN_____ @rustlang
I really wanted to write `expr?` or `future.from_err()` instead of `.map_err(MyError::helper_function)`. stupid, i know. turned into a exercise.
1 reply 0 retweets 0 likes
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.
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.