builder/tests/02-create-builder.rs says "Before moving on, have the macro also generate:" and it shows the CommandBuilder struct based on the input Command type, but with each field made Optional if it's not already.
I understand why they'd be optional -- the builder pattern requires adding individual fields before construction of the output type -- but is dynamically making fields optional an intended piece of test 2? It comes quite early in the workshop, but doing so seems rather complicated.
In particular, it seems to assume knowledge gained in test 6 (see #12) regarding detection of whether a field has Option (because one field is already Option) plus knowledge of modifying field types.
Simpler tasks, like building an ident, have a resource link, but there's no comment about type modification.
Sorry if I'm missing an obvious alternative for adding Option!
builder/tests/02-create-builder.rs
says "Before moving on, have the macro also generate:" and it shows theCommandBuilder
struct based on the inputCommand
type, but with each field madeOption
al if it's not already.I understand why they'd be optional -- the builder pattern requires adding individual fields before construction of the output type -- but is dynamically making fields optional an intended piece of test 2? It comes quite early in the workshop, but doing so seems rather complicated.
In particular, it seems to assume knowledge gained in test 6 (see #12) regarding detection of whether a field has
Option
(because one field is alreadyOption
) plus knowledge of modifying field types.Simpler tasks, like building an ident, have a resource link, but there's no comment about type modification.
Sorry if I'm missing an obvious alternative for adding
Option
!