// check-pass struct TestA {} struct TestB {} impl TestTrait for TestA { type Output = (); } impl TestTrait for TestB { type Output = (); } trait TestTrait { type Output; } impl TestTrait for GreeterOutput where A: TestTrait, B: TestTrait, { type Output = (); } enum GreeterOutput where A: TestTrait, B: TestTrait, { SayHello(A), SayGoodbye(B), } trait Greeter { fn test_func(&self, func: &str) -> impl TestTrait { match func { "SayHello" => GreeterOutput::SayHello(TestA {}), "SayGoodbye" => GreeterOutput::SayGoodbye(TestB {}), _ => GreeterOutput::SayHello(TestA {}), } } } fn main() { println!("Hello, world!"); }