#[derive(Default)]
pub struct Builder<T:Fn()> {
decoder:Option<T>
}
impl<T:Fn()> Builder<T> {
pub fn new() -> Self {
//Builder {
// decoder:None,
//}
Builder::default()
}
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0277]: the trait bound `T: Default` is not satisfied
--> src/lib.rs:11:9
|
11 | Builder::default()
| ^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `T`
|
= note: required because of the requirements on the impl of `Default` for `Builder<T>`
= note: required by `std::default::Default::default`
help: consider further restricting this bound
|
6 | impl<T:Fn() + Default> Builder<T> {
| ^^^^^^^^^
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.
Can someone explain this? Thanks