Skip to content

Commit b4de659

Browse files
authored
fix(option2): Rename uninformative variables (#675)
Renaming uninformative names like `optional_value`, `value`, `optional_values_vec` and `value` helps users distinguish between the two parts of the task.
1 parent a37a881 commit b4de659

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

exercises/option/option2.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
// I AM NOT DONE
55

66
fn main() {
7-
let optional_value = Some(String::from("rustlings"));
7+
let optional_word = Some(String::from("rustlings"));
88
// TODO: Make this an if let statement whose value is "Some" type
9-
value = optional_value {
10-
println!("the value of optional value is: {}", value);
9+
word = optional_word {
10+
println!("The word is: {}", word);
1111
} else {
12-
println!("The optional value doesn't contain anything!");
12+
println!("The optional word doesn't contain anything");
1313
}
1414

15-
let mut optional_values_vec: Vec<Option<i8>> = Vec::new();
15+
let mut optional_integers_vec: Vec<Option<i8>> = Vec::new();
1616
for x in 1..10 {
17-
optional_values_vec.push(Some(x));
17+
optional_integers_vec.push(Some(x));
1818
}
1919

2020
// TODO: make this a while let statement - remember that vector.pop also adds another layer of Option<T>
2121
// You can stack `Option<T>`'s into while let and if let
22-
value = optional_values_vec.pop() {
23-
println!("current value: {}", value);
22+
integer = optional_integers_vec.pop() {
23+
println!("current value: {}", integer);
2424
}
2525
}

0 commit comments

Comments
 (0)