mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-07 03:09:19 +00:00
24 lines
643 B
Rust
24 lines
643 B
Rust
// option1.rs
|
|
// Make me compile! Execute `rustlings hint option1` for hints
|
|
|
|
// you can modify anything EXCEPT for this function's sig
|
|
fn print_number(maybe_number: Option<u16>) {
|
|
println!("printing: {}", maybe_number.unwrap());
|
|
}
|
|
|
|
fn main() {
|
|
print_number(Option::Some(13));
|
|
print_number(Option::Some(99));
|
|
|
|
let mut numbers: [Option<u16>; 5] = [
|
|
Option::Some(0), Option::Some(0), Option::Some(0), Option::Some(0), Option::Some(0)
|
|
];
|
|
for iter in 0..5 {
|
|
let number_to_add: u16 = {
|
|
((iter * 5) + 2) / (4 * 16)
|
|
};
|
|
|
|
numbers[iter as usize] = Option::Some(number_to_add);
|
|
}
|
|
}
|