Created
March 17, 2020 19:10
-
-
Save tstellanova/72fb94d5298308af2ef365a3e50cae5f to your computer and use it in GitHub Desktop.
Align the associated error types of multiple traits (when you know they're actually the same type)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait T { | |
| type TErr; | |
| } | |
| trait U { | |
| type UErr; | |
| } | |
| #[derive(Debug)] | |
| struct S; | |
| impl T for S { | |
| type TErr = &'static str; | |
| } | |
| impl U for S { | |
| type UErr = &'static str; | |
| } | |
| fn setup() -> ( | |
| impl T<TErr = &'static str> + U<UErr = &'static str> + std::fmt::Debug, | |
| u32, | |
| ) { | |
| (S, 5) | |
| } | |
| fn main() { | |
| let (s, _) = setup(); | |
| dbg!(s); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment