rustlings/exercises/option/option1.rs

27 lines
568 B
Rust
Raw Normal View History

2020-04-02 19:40:59 +07:00
// option1.rs
//
// Make me compile!
//
// If you need help, open the corresponding README.md or run: rustlings hint option1
2020-03-06 03:52:54 +07:00
2020-04-02 19:40:59 +07:00
// I AM NOT DONE
2020-03-06 03:52:54 +07:00
// You can modify anything EXCEPT for this function's sig
2020-03-06 03:52:54 +07:00
fn print_number(maybe_number: Option<u16>) {
2020-03-12 00:44:10 +07:00
println!("printing: {}", maybe_number.unwrap());
2020-03-06 03:52:54 +07: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-06 03:52:54 +07:00
};
numbers[iter as usize] = number_to_add;
2020-03-06 03:52:54 +07:00
}
2020-03-12 00:44:10 +07:00
}