struct GroceriesSection {
section: String,
items: Vec<String>,
}
struct Recipe {
recipe: String,
ingredients: Vec<String>,
}
struct ShoppingList {
recipes_msg: String,
recipes: Vec<String>,
checklist_msg: String,
checklist: Vec<String>,
list_msg: String,
list: Vec<String>,
}
Here the types do not make clear which items are used in which places. For example GroceriesSection::String
is totally unrelated to the items in Recipe::ingredients
. However GroceriesSection::items
is the same. So rather than all of these being just String
you could have types like:
#[derive(Shrinkwrap)]
struct RecipeName(String);
#[derive(Shrinkwrap)]
struct Ingredient{ name: String }
``
etc. (using shrinkwraprs 3)
This would make things like `ShoppingList` much easier to understand by looking at the struct.