Skip to content

Unhelpful hint in formatting chapter #1898

Open
@holly-hacker

Description

@holly-hacker

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions