builder-pattern icon indicating copy to clipboard operation
builder-pattern copied to clipboard

Provide meaningful compile error when build fails

Open SeokminHong opened this issue 4 years ago • 0 comments

When the required fields are not properly provided, the compiler cannot deduce the build function. In that time, the compile error message would be like this:

no method named `build` found for struct `TestBuilder<...>` in the current scope

It will be helpful that the compiler suggests missing required fields like this:

Cannot build `Test` because following fields are required:
  - name: String
  - age: u8

It may be easily implemented if the Specialization feature is implemented, but the feature is not stable.

SeokminHong avatar Aug 24 '21 10:08 SeokminHong