inquire
inquire copied to clipboard
less verbosity in ui::Color::Rgb{...}
I suggest replacing it with ui::Color::Rgb(u8, u8, u8)
I agree it has its benefits. Using a struct provides better readability when reading the values (e.g. color.r instead of color.0), but I think only the underlying terminal library actually reads these values, while we create them. While your suggestion makes it much less verbose to create them :)
Would you be willing to make a PR?
Oh, I didn't think about color.r that's true. Idk, I'm kinda busy...
Would you ever be able to use color.r if the fields are only on one variant of the enum? To get the values out you'd need to do something like if let Color::Rgb{r, g, b} = color { ... } which could just as easily be if let Color::Rgb(r, g, b) = color { ... }.
That said, I quite like the explicitness of naming the fields here even when it might not be necessary. What about adding an rgb(u8, u8, u8) static method to Color that handles the verbosity when creating instances?
Both your points are perfect to me. It can get cumbersome on pattern matching and the like but I quite like to be explicit as well. Let's go with the static method.