This struct holds a field that needs to have a lot of different traits.
struct ManyRequirements<T>
where
T:Ord,
T:Copy,
T:Clone,
T:Iterator,
T:Display
{
something: T
}
I want to write methods for it that work regardless of T, like a "new" method for example. I just want to be able to say ManyRequirements::new() and have it work properly. But if I tried,
impl ManyRequirements {
fn new() {
}
}
or
impl<T> ManyRequirements<T> {
fn new() {
}
}
I get
the trait bound `T: Ord` is not satisfied
the trait `Ord` is not implemented for `T`
repeated for each trait T failed to be implemented for. The only thing that works is
impl <T> ManyRequirements<T>
where
T:Ord,
T:Copy,
T:Clone,
T:Iterator,
T:Display
{
}
Is there a shorter way to say "T can be whatever"? Something like
impl <_> ManyRequirements<_>
{
}