Closed sunjay closed 3 years ago
@sunjay Yes, I would like to continue working on this.
I have a question about this to-do:
change the macro that defines COLORS and COLOR_NAMES to define those constants within an impl Color block (this should create a single set of those constants that actually contains ALL the colors supported in this crate)
As we already noticed in the previous PR, defining these variables within an impl Color
block won't work because static variables are not allowed as associated items in structs. So we should maybe continue using the functions that you came up with instead?
As we already noticed in the previous PR, defining these variables within an
impl Color
block won't work because static variables are not allowed as associated items in structs. So we should maybe continue using the functions that you came up with instead?
Oops! You are totally right. Yes, please use the associated functions instead. Thanks!
In #171, I suggested that we move the color constants from the
color
module into theColor
struct itself. After merging #186, I spent some time thinking about it a bit more and wondered if we might want to take a different approach.Here are some problems with how we currently define color constants and how we show them in the documentation:
Color
. Most people use the color name strings instead (e.g."cherry red"
) because they are more convenient and more prominently used throughout the docs. The constants make it so you have to scroll pretty far to see the rest of the documentation forColor
.COLORS
andCOLOR_NAMES
static variables don't actually contain all of the colors in the crate. We split the colors between two places so those constants only contain the colors that are defined nearby.To solve all of this, I am now suggesting that we move all of the color constants to a single
color_consts
module. This will allow us to make a single, complete list of all the supported color names and avoid filling theColor
struct documentation with information that is rarely used.To-do
[x] create a new file
src/color/color_consts.rs
[x] move the contents of the
extra_colors
module to that file[x] move the documentation for
extra_colors
to that file (don't forget to replace///
with//!
)[x] move the color constants currently defined on
Color
into that file (there should no longer be any color constants inColor
)[x] change the macro that defines
COLORS
andCOLOR_NAMES
to define those constants within animpl Color
block (this should create a single set of those constants that actually contains ALL the colors supported in this crate)[x] stop re-exporting
extra_colors
and re-exportcolor_consts
instead[x] fix compiler resulting errors
[x] update the documentation
[x] see the To-do list in #171 for more ideas of what you might need to do
[x] optional: reference
color_consts
at the bottom of theColor
struct documentation[ ] optional: reference
color_consts
in the documentation of methods that takeInto<Color>
Please don't hesitate to ask questions in the comments below or on Zulip!
cc @noeddl in case you're interested in doing a follow up from #186.