cargo-bundle icon indicating copy to clipboard operation
cargo-bundle copied to clipboard

About getter pattern

Open wiiznokes opened this issue 7 months ago • 1 comments

Looking at the code a little, I saw that a good part of the structures use a getter pattern. I find this a shame because in fact, the Setting or BundleSettings structure is still missing a lot of keywords, and having to implement a setter each time is redundant. It feels like Java.

In addition, it does not contribute much in the majority of cases because

  • the structure is passed between functions as a non-mutable ref, so there is no risk of modifying it inadvertently.

  • getters provide an impl of default(), which can be automatically done with serde.

So can I start adding public fields?

wiiznokes avatar Nov 14 '23 17:11 wiiznokes

Also, why not use an enum for the different targets (deb, msi, ...)

We could imagine a something like this:

enum BundleSettings {
   name: Option<String>,
   deb: Deb(BundleDebSettings),
   msi: Msi(BundleMsiSettings),
}

And having this out of the box: [package.metadata.bundle.example.hello.deb]

wiiznokes avatar Nov 14 '23 18:11 wiiznokes