Closed
Description
I was wondering if requiring an explicit derive(Default) for empty struct makes sense. It feels right that empty (for whatever reason) struct should derive Default, well, by default :)
This is my first issue in rust-lang, so any feedback is welcome. If such suggestion makes sense, I'd like to implement it with very little guidance from more experienced Rustaceans.
//#[derive(Default)]
struct X;
fn f<T: Default>(_: T) {
()
}
fn main() {
f(X);
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0277]: the trait bound `X: std::default::Default` is not satisfied
--> src/main.rs:9:7
|
4 | fn f<T: Default>(_: T) {
| - ------- required by this bound in `f`
...
9 | f(X);
| ^ the trait `std::default::Default` is not implemented for `X`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground`.
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
No labels