Conditionally implement a Rust trait only if a type constraint is satisfied
问题 I have the following struct: pub struct Foo<T> { some_value: T, } impl<T> Foo<T> { pub fn new(value: T) -> Self { Self { some_value: value } } } // Implement `Default()`, assuming that the underlying stored type // `T` also implements `Default`. impl<T> Default for Foo<T> where T: Default, { fn default() -> Self { Self::new(T::default()) } } I would like Foo::default() to be available if T implements Default , but not available otherwise. Is it possible to specify "conditional implementation"