@ -4,22 +4,22 @@
// I AM NOT DONE
fn main ( ) {
let optional_ value = Some ( String ::from ( "rustlings" ) ) ;
let optional_ word = Some ( String ::from ( "rustlings" ) ) ;
// TODO: Make this an if let statement whose value is "Some" type
value = optional_value {
println! ( " the value of optional value is: {}", value ) ;
word = optional_word {
println! ( " The word is: {}", word ) ;
} else {
println! ( "The optional value doesn't contain anything! ") ;
println! ( "The optional word doesn't contain anything ") ;
}
let mut optional_ value s_vec: Vec < Option < i8 > > = Vec ::new ( ) ;
let mut optional_ integer s_vec: Vec < Option < i8 > > = Vec ::new ( ) ;
for x in 1 .. 10 {
optional_ value s_vec. push ( Some ( x ) ) ;
optional_ integer s_vec. push ( Some ( x ) ) ;
}
// TODO: make this a while let statement - remember that vector.pop also adds another layer of Option<T>
// You can stack `Option<T>`'s into while let and if let
value = optional_value s_vec. pop ( ) {
println! ( "current value: {}" , value ) ;
integer = optional_integer s_vec. pop ( ) {
println! ( "current value: {}" , integer ) ;
}
}