-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Closed
Labels
T-langRelevant to the language teamRelevant to the language team
Description
The following code fails to compile:
trait Foo {}
trait Bar {}
fn main() {
let x: Box<Foo + Bar> = unimplemented!();
}You can only box multiple traits when the additional bounds are built in. This seems like an extremely odd restriction. Is there an intention to remove it at some point? The workaround is incredibly annoying:
trait Foo {}
trait Bar {}
trait FooAndBar: Foo + Bar {}
impl<T> FooAndBar for T where T: Foo + Bar {}
fn main() {
let x: Box<FooAndBar> = unimplemented!();
}The number of these traits grows quite rapidly as you need multiple combinations of various traits. In Diesel's case, many of these will end up needing to be part of the public API which is leading to a lot of confusing and hard to discover types.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
T-langRelevant to the language teamRelevant to the language team