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

False positive result on option2 exercise #655

Open
gwilherm opened this issue Feb 20, 2021 · 0 comments
Open

False positive result on option2 exercise #655

gwilherm opened this issue Feb 20, 2021 · 0 comments
Labels
C-potential-rewrite Concerns an exercise that may need to be rewritten, given time.

Comments

@gwilherm
Copy link

Hello,

I first wrote this solution for the first part of option2 and it was marked as correct

fn main() {
    let optional_value = Some(String::from("rustlings"));
    // TODO: Make this an if let statement whose value is "Some" type
    if let value = optional_value {
        println!("the value of optional value is: {}", value.unwrap());
    } else {
        println!("The optional value doesn't contain anything!");
    }
    // ....
}

The code could be moved in a function and be tested with Some and None :

fn print_value(optional_value: Option<String>) {
    // TODO: Make this an if let statement whose value is "Some" type
    value = optional_value {
        println!("the value of optional value is: {}", value);
    } else {
        println!("The optional value doesn't contain anything!");
    }
}

fn main() {
    print_value(Some(String::from("rustlings")));
    print_value(None);
    // ....
}
@mo8it mo8it added the C-potential-rewrite Concerns an exercise that may need to be rewritten, given time. label Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-potential-rewrite Concerns an exercise that may need to be rewritten, given time.
Projects
None yet
Development

No branches or pull requests

2 participants