Skip to content

State scope of builder pattern #122

Open
@simonsan

Description

@simonsan

Perhaps the builder pattern doc should mention that this is about initializing private struct fields.
There is no point in using builder (or multiple constructors which the builder pattern is supposed to help to avoid) if all fields are public.

Originally posted by @zoechi in #64 (comment)

Also mentioning a complementary relationship between a Default-trait and the builder pattern could be a nice addition?

I think it's fair to say that default impls and builders complement each other. It's often useful to use both in some combination. The derive builder crate supports this. In specific cases you may only need one or the other. I don't think either in isolation in all cases is a silver bullet for struct creation.

Originally posted by @softprops in #64 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-patternArea: Content about PatternsC-enhancementCategory: Enhancements to content

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions