mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-12 05:39:19 +00:00
Fixed option1.rs, and completed exercise
This commit is contained in:
parent
ab28f35935
commit
1059fbe390
@ -1,7 +1,6 @@
|
|||||||
// option1.rs
|
// option1.rs
|
||||||
// Make me compile! Execute `rustlings hint option1` for hints
|
// Make me compile! Execute `rustlings hint option1` for hints
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
// you can modify anything EXCEPT for this function's signature
|
// you can modify anything EXCEPT for this function's signature
|
||||||
fn print_number(maybe_number: Option<u16>) {
|
fn print_number(maybe_number: Option<u16>) {
|
||||||
@ -9,15 +8,14 @@ fn print_number(maybe_number: Option<u16>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
print_number(13);
|
print_number(Some(13));
|
||||||
print_number(99);
|
print_number(Some(99));
|
||||||
|
|
||||||
let mut numbers: [Option<u16>; 5];
|
let mut numbers: [Option<u16>; 5] = [None; 5]; // Issue #395 on rustlings
|
||||||
for iter in 0..5 {
|
for iter in 0..5 {
|
||||||
let number_to_add: u16 = {
|
let number_to_add: u16 = {
|
||||||
((iter * 1235) + 2) / (4 * 16)
|
((iter * 1235) + 2) / (4 * 16)
|
||||||
};
|
};
|
||||||
|
numbers[iter as usize] = Some(number_to_add);
|
||||||
numbers[iter as usize] = number_to_add;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user