estebank / makeit

Zero-overhead type-safe builder pattern `derive` macro for your Rust structs
223 stars 11 forks source link

Fields should not require `: Default` when a default is given through `#[default(value)]` #12

Closed tqwewe closed 2 years ago

tqwewe commented 2 years ago

Given the following code:

#[derive(Builder)]
struct MyStruct {
    #[default(Foo(0)]
    one: Foo,
}

struct Foo(i32);

The code fails since Foo doesn't implement Default. But this should not be the case since I'm providing a default through the attribute, and adding the where Foo: Default is uncecessary at that point.

where
  Foo: Default

Should only be applied if #[default] is given without a value.