Skip to content

Enhancement (09_strings/strings2.rs): confusing comment #2230

Open
@Andebugulin

Description

@Andebugulin

When I was doing rustlings, I got confused in the comment of this code. I will put here the whole rustling since it is not big:

// TODO: Fix the compiler error in the `main` function without changing this function.
fn is_a_color_word(attempt: &str) -> bool {
    attempt == "green" || attempt == "blue" || attempt == "red"
}

fn main() {
    let word = String::from("green"); // Don't change this line.

    if is_a_color_word(word) {
        println!("That is a color word I know!");
    } else {
        println!("That is not a color word I know.");
    }
}

Main confusion cause is the word this. At first I thought that this might relate to main function because it goes right after it being mentioned in the sentence, then I thought that it might mean function that is directly below.

I believe it is possible to completely eliminate the confusion.


Suggestion:

  • replace this with the actual name of the funciton is_a_color_word

the whole comment would then look like:

// TODO: Fix the compiler error in the `main` function without changing `is_a_color_word` function.

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