Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhelpful hint in formatting chapter #1898

Open
holly-hacker opened this issue Nov 25, 2024 · 0 comments
Open

Unhelpful hint in formatting chapter #1898

holly-hacker opened this issue Nov 25, 2024 · 0 comments

Comments

@holly-hacker
Copy link

holly-hacker commented Nov 25, 2024

In chapter 1.2.3 Formatting, one of the exercises given to the users is to implement the Display trait for a color struct to print the hex code.

One of the hints given says "The formula for calculating a color in the RGB color space is: RGB = (R*65536)+(G*256)+B , (when R is RED, G is GREEN and B is BLUE)". I don't think this is a very good hint, as it requires casting the RGB values from u8 to u32 which is a topic that is only covered in chapter 5.

My colleague was trying this chapter and found it difficult to solve the exercise, claiming that looking at the hints was "a mistake". Instead, after messing around with casting he ended up solving it by using write!(f, "RGB ({red}, {green}, {blue}) 0x{red:02X}{green:02X}{blue:02X}").

I propose changing this hint to not need casts or explicitly telling the reader how they can cast between u8 and u32 values while referring them to the future chapter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant