rustlings
rustlings copied to clipboard
False positive result on option2 exercise
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);
// ....
}