File tree Expand file tree Collapse file tree 8 files changed +43
-0
lines changed Expand file tree Collapse file tree 8 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,8 @@ bin = [
86
86
{ name = " modules2_sol" , path = " ../solutions/09_modules/modules2.rs" },
87
87
{ name = " modules3" , path = " ../exercises/09_modules/modules3.rs" },
88
88
{ name = " modules3_sol" , path = " ../solutions/09_modules/modules3.rs" },
89
+ { name = " modules4" , path = " ../exercises/09_modules/modules4.rs" },
90
+ { name = " modules4_sol" , path = " ../solutions/09_modules/modules4.rs" },
89
91
{ name = " hashmaps1" , path = " ../exercises/11_hashmaps/hashmaps1.rs" },
90
92
{ name = " hashmaps1_sol" , path = " ../solutions/11_hashmaps/hashmaps1.rs" },
91
93
{ name = " hashmaps2" , path = " ../exercises/11_hashmaps/hashmaps2.rs" },
Original file line number Diff line number Diff line change
1
+
2
+
3
+ pub fn get_piece ( ) {
4
+ println ! ( "Got cake piece!" ) ;
5
+ }
Original file line number Diff line number Diff line change
1
+ pub fn get_fav_fruit ( ) {
2
+ println ( "Got your favourite fruit!" )
3
+ }
Original file line number Diff line number Diff line change
1
+ //TODO: fix the compiler error for missing modules.
2
+
3
+ fn main ( ) {
4
+ cake:: get_piece ( ) ;
5
+ fruit:: get_fav_fruit ( ) ;
6
+ }
Original file line number Diff line number Diff line change @@ -544,6 +544,18 @@ hint = """
544
544
`use` statement for these two to bring them into scope. You can use nested
545
545
paths to bring these two in using only one line."""
546
546
547
+ [[exercises ]]
548
+ name = " modules4"
549
+ dir = " 09_modules"
550
+ test = false
551
+ hint = """
552
+ The mod.rs is trying to use the modules from the file cake.rs and fruit directory.
553
+ Complete the `mod` statements to fit the use in `main`.
554
+
555
+ Learn more in The Book:
556
+ https://doc.rust-lang.org/book/ch07-05-separating-modules-into-different-files.html
557
+ """
558
+
547
559
# HASHMAPS
548
560
549
561
[[exercises ]]
Original file line number Diff line number Diff line change
1
+
2
+
3
+ pub fn get_piece ( ) {
4
+ println ! ( "Got cake piece!" ) ;
5
+ }
Original file line number Diff line number Diff line change
1
+ pub fn get_fav_fruit ( ) {
2
+ println ( "Got your favourite fruit!" )
3
+ }
Original file line number Diff line number Diff line change
1
+ mod cake;
2
+ mod fruit;
3
+
4
+ fn main ( ) {
5
+ cake:: get_piece ( ) ;
6
+ fruit:: get_fav_fruit ( ) ;
7
+ }
You can’t perform that action at this time.
0 commit comments