Skip to content

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

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

Open
Andebugulin opened this issue Apr 2, 2025 · 1 comment · May be fixed by #2231
Open

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

Andebugulin opened this issue Apr 2, 2025 · 1 comment · May be fixed by #2231

Comments

@Andebugulin
Copy link

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.
@brambhattabhishek
Copy link

/assign

@akshatcoder-hash akshatcoder-hash linked a pull request Apr 6, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants