forked from rust-lang/rustlings
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
16 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
// This shopping list program isn't compiling! | ||
// Use your knowledge of generics to fix it. | ||
|
||
// I AM NOT DONE | ||
|
||
fn main() { | ||
let mut shopping_list: Vec<?> = Vec::new(); | ||
let mut shopping_list: Vec<&str> = Vec::new(); | ||
shopping_list.push("milk"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
// option1.rs | ||
// Make me compile! Execute `rustlings hint option1` for hints | ||
|
||
// I AM NOT DONE | ||
|
||
// 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(13); | ||
print_number(99); | ||
print_number(Some(13)); | ||
print_number(Some(99)); | ||
|
||
let mut numbers: [Option<u16>; 5]; | ||
let mut numbers: [Option<u16>; 5] = [None; 5]; | ||
for iter in 0..5 { | ||
let number_to_add: u16 = { | ||
((iter * 1235) + 2) / (4 * 16) | ||
}; | ||
|
||
numbers[iter as usize] = number_to_add; | ||
numbers[iter as usize] = Some(number_to_add); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters