rustlings/exercises/options/options1.rs

24 lines
548 B
Rust
Raw Normal View History

2022-07-14 10:34:50 -05:00
// options1.rs
// Execute `rustlings hint options1` or use the `hint` watch subcommand for a hint.
2020-03-05 14:52:54 -06:00
2020-04-02 06:40:59 -06:00
// I AM NOT DONE
2020-03-05 14:52:54 -06:00
// you can modify anything EXCEPT for this function's signature
2020-03-05 14:52:54 -06:00
fn print_number(maybe_number: Option<u16>) {
2020-03-11 11:44:10 -06:00
println!("printing: {}", maybe_number.unwrap());
2020-03-05 14:52:54 -06:00
}
fn main() {
print_number(13);
print_number(99);
let mut numbers: [Option<u16>; 5];
for iter in 0..5 {
let number_to_add: u16 = {
((iter * 1235) + 2) / (4 * 16)
2020-03-05 14:52:54 -06:00
};
numbers[iter as usize] = number_to_add;
2020-03-05 14:52:54 -06:00
}
2020-03-11 11:44:10 -06:00
}