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

Closed
gwilherm opened this issue Feb 20, 2021 · 1 comment
Closed

False positive result on option2 exercise #655

gwilherm opened this issue Feb 20, 2021 · 1 comment
Labels
A-exercises Area: Exercises C-enhancement Category: Enhancement

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
Copy link
Contributor

mo8it commented Sep 3, 2024

There is more discussion about this exercise in #1990 now.

@mo8it mo8it closed this as completed Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-exercises Area: Exercises C-enhancement Category: Enhancement
Projects
None yet
Development

No branches or pull requests

2 participants