Suppose I have a struct S<T> and I want implement it to trait Default with different constraints of generic type T:
struct S<T> { ... }
impl<T> Default for S<T>
where
T: Ord
{
fn default() -> Self {
Self::new()
}
}
impl<T> Default for S<T>
where
T: Ord + Default
{
fn default() -> Self {
Self::build(T::default())
}
}
However, the compiler complains:
error[E0119]: conflicting implementations of trait std::default::Default for type S<_>
Is there any way to compile such code?