File tree Expand file tree Collapse file tree 4 files changed +48
-2
lines changed
Expand file tree Collapse file tree 4 files changed +48
-2
lines changed Original file line number Diff line number Diff line change 1+ ### Option
2+
3+ #### Book Sections
4+
5+ To learn about Option<T >, check out these links:
6+
7+ - [ Option Enum Format] ( https://doc.rust-lang.org/stable/book/ch10-01-syntax.html#in-enum-definitions )
8+ - [ Option Module Documentation] ( https://doc.rust-lang.org/std/option/ )
9+ - [ Option Enum Documentation] ( https://doc.rust-lang.org/std/option/enum.Option.html )
Original file line number Diff line number Diff line change 1+ //option1.rs
2+ //Make me compile! Execute `rustlings hint option1` for hints
3+
4+ //I AM NOT DONE
5+
6+ //you can modify anything EXCEPT for this function's sig
7+ fn print_number ( maybe_number : Option < u16 > ) {
8+ println ! ( "printing: {}" , * maybe_number) ;
9+ }
10+
11+ fn main ( ) {
12+ print_number ( 13 ) ;
13+ print_number ( 99 ) ;
14+
15+ let mut numbers: [ Option < u16 > ; 5 ] ;
16+ for iter in 0 ..5 {
17+ let number_to_add: u16 = {
18+ ( ( iter * 5 ) + 2 ) / ( 4 * 16 ) ;
19+ } ;
20+
21+ numbers[ iter] = number_to_add;
22+ }
23+ }
Original file line number Diff line number Diff line change @@ -701,4 +701,18 @@ path = "exercises/conversions/from_str.rs"
701701mode = " test"
702702hint = """
703703If you've already solved try_from_into.rs, then this is almost a copy-paste.
704- Otherwise, go ahead and solve try_from_into.rs first."""
704+ Otherwise, go ahead and solve try_from_into.rs first."""
705+
706+ [[exercises ]]
707+ name = " option1"
708+ path = " exercises/option/option1.rs"
709+ mode = " compile"
710+ hint = """
711+ Check out some functions of Option:
712+ is_some
713+ is_none
714+ unwrap
715+
716+ and:
717+ pattern matching
718+ """
You can’t perform that action at this time.
0 commit comments