Skip to content

Commit 055f0af

Browse files
committed
init commit
0 parents  commit 055f0af

File tree

219 files changed

+4865
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

219 files changed

+4865
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Cargo.lock
2+
target/
3+
.vscode/

.rustlings-state.txt

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
DON'T EDIT THIS FILE!
2+
3+
move_semantics2
4+
5+
intro1
6+
intro2
7+
variables1
8+
variables2
9+
variables3
10+
variables4
11+
variables5
12+
variables6
13+
functions1
14+
functions2
15+
functions3
16+
functions4
17+
functions5
18+
if1
19+
if2
20+
if3
21+
quiz1
22+
primitive_types1
23+
primitive_types2
24+
primitive_types3
25+
primitive_types4
26+
primitive_types5
27+
primitive_types6
28+
vecs1
29+
vecs2
30+
move_semantics1

Cargo.toml

+222
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
bin = [
2+
{ name = "intro1", path = "exercises/00_intro/intro1.rs" },
3+
{ name = "intro1_sol", path = "solutions/00_intro/intro1.rs" },
4+
{ name = "intro2", path = "exercises/00_intro/intro2.rs" },
5+
{ name = "intro2_sol", path = "solutions/00_intro/intro2.rs" },
6+
{ name = "variables1", path = "exercises/01_variables/variables1.rs" },
7+
{ name = "variables1_sol", path = "solutions/01_variables/variables1.rs" },
8+
{ name = "variables2", path = "exercises/01_variables/variables2.rs" },
9+
{ name = "variables2_sol", path = "solutions/01_variables/variables2.rs" },
10+
{ name = "variables3", path = "exercises/01_variables/variables3.rs" },
11+
{ name = "variables3_sol", path = "solutions/01_variables/variables3.rs" },
12+
{ name = "variables4", path = "exercises/01_variables/variables4.rs" },
13+
{ name = "variables4_sol", path = "solutions/01_variables/variables4.rs" },
14+
{ name = "variables5", path = "exercises/01_variables/variables5.rs" },
15+
{ name = "variables5_sol", path = "solutions/01_variables/variables5.rs" },
16+
{ name = "variables6", path = "exercises/01_variables/variables6.rs" },
17+
{ name = "variables6_sol", path = "solutions/01_variables/variables6.rs" },
18+
{ name = "functions1", path = "exercises/02_functions/functions1.rs" },
19+
{ name = "functions1_sol", path = "solutions/02_functions/functions1.rs" },
20+
{ name = "functions2", path = "exercises/02_functions/functions2.rs" },
21+
{ name = "functions2_sol", path = "solutions/02_functions/functions2.rs" },
22+
{ name = "functions3", path = "exercises/02_functions/functions3.rs" },
23+
{ name = "functions3_sol", path = "solutions/02_functions/functions3.rs" },
24+
{ name = "functions4", path = "exercises/02_functions/functions4.rs" },
25+
{ name = "functions4_sol", path = "solutions/02_functions/functions4.rs" },
26+
{ name = "functions5", path = "exercises/02_functions/functions5.rs" },
27+
{ name = "functions5_sol", path = "solutions/02_functions/functions5.rs" },
28+
{ name = "if1", path = "exercises/03_if/if1.rs" },
29+
{ name = "if1_sol", path = "solutions/03_if/if1.rs" },
30+
{ name = "if2", path = "exercises/03_if/if2.rs" },
31+
{ name = "if2_sol", path = "solutions/03_if/if2.rs" },
32+
{ name = "if3", path = "exercises/03_if/if3.rs" },
33+
{ name = "if3_sol", path = "solutions/03_if/if3.rs" },
34+
{ name = "quiz1", path = "exercises/quizzes/quiz1.rs" },
35+
{ name = "quiz1_sol", path = "solutions/quizzes/quiz1.rs" },
36+
{ name = "primitive_types1", path = "exercises/04_primitive_types/primitive_types1.rs" },
37+
{ name = "primitive_types1_sol", path = "solutions/04_primitive_types/primitive_types1.rs" },
38+
{ name = "primitive_types2", path = "exercises/04_primitive_types/primitive_types2.rs" },
39+
{ name = "primitive_types2_sol", path = "solutions/04_primitive_types/primitive_types2.rs" },
40+
{ name = "primitive_types3", path = "exercises/04_primitive_types/primitive_types3.rs" },
41+
{ name = "primitive_types3_sol", path = "solutions/04_primitive_types/primitive_types3.rs" },
42+
{ name = "primitive_types4", path = "exercises/04_primitive_types/primitive_types4.rs" },
43+
{ name = "primitive_types4_sol", path = "solutions/04_primitive_types/primitive_types4.rs" },
44+
{ name = "primitive_types5", path = "exercises/04_primitive_types/primitive_types5.rs" },
45+
{ name = "primitive_types5_sol", path = "solutions/04_primitive_types/primitive_types5.rs" },
46+
{ name = "primitive_types6", path = "exercises/04_primitive_types/primitive_types6.rs" },
47+
{ name = "primitive_types6_sol", path = "solutions/04_primitive_types/primitive_types6.rs" },
48+
{ name = "vecs1", path = "exercises/05_vecs/vecs1.rs" },
49+
{ name = "vecs1_sol", path = "solutions/05_vecs/vecs1.rs" },
50+
{ name = "vecs2", path = "exercises/05_vecs/vecs2.rs" },
51+
{ name = "vecs2_sol", path = "solutions/05_vecs/vecs2.rs" },
52+
{ name = "move_semantics1", path = "exercises/06_move_semantics/move_semantics1.rs" },
53+
{ name = "move_semantics1_sol", path = "solutions/06_move_semantics/move_semantics1.rs" },
54+
{ name = "move_semantics2", path = "exercises/06_move_semantics/move_semantics2.rs" },
55+
{ name = "move_semantics2_sol", path = "solutions/06_move_semantics/move_semantics2.rs" },
56+
{ name = "move_semantics3", path = "exercises/06_move_semantics/move_semantics3.rs" },
57+
{ name = "move_semantics3_sol", path = "solutions/06_move_semantics/move_semantics3.rs" },
58+
{ name = "move_semantics4", path = "exercises/06_move_semantics/move_semantics4.rs" },
59+
{ name = "move_semantics4_sol", path = "solutions/06_move_semantics/move_semantics4.rs" },
60+
{ name = "move_semantics5", path = "exercises/06_move_semantics/move_semantics5.rs" },
61+
{ name = "move_semantics5_sol", path = "solutions/06_move_semantics/move_semantics5.rs" },
62+
{ name = "structs1", path = "exercises/07_structs/structs1.rs" },
63+
{ name = "structs1_sol", path = "solutions/07_structs/structs1.rs" },
64+
{ name = "structs2", path = "exercises/07_structs/structs2.rs" },
65+
{ name = "structs2_sol", path = "solutions/07_structs/structs2.rs" },
66+
{ name = "structs3", path = "exercises/07_structs/structs3.rs" },
67+
{ name = "structs3_sol", path = "solutions/07_structs/structs3.rs" },
68+
{ name = "enums1", path = "exercises/08_enums/enums1.rs" },
69+
{ name = "enums1_sol", path = "solutions/08_enums/enums1.rs" },
70+
{ name = "enums2", path = "exercises/08_enums/enums2.rs" },
71+
{ name = "enums2_sol", path = "solutions/08_enums/enums2.rs" },
72+
{ name = "enums3", path = "exercises/08_enums/enums3.rs" },
73+
{ name = "enums3_sol", path = "solutions/08_enums/enums3.rs" },
74+
{ name = "strings1", path = "exercises/09_strings/strings1.rs" },
75+
{ name = "strings1_sol", path = "solutions/09_strings/strings1.rs" },
76+
{ name = "strings2", path = "exercises/09_strings/strings2.rs" },
77+
{ name = "strings2_sol", path = "solutions/09_strings/strings2.rs" },
78+
{ name = "strings3", path = "exercises/09_strings/strings3.rs" },
79+
{ name = "strings3_sol", path = "solutions/09_strings/strings3.rs" },
80+
{ name = "strings4", path = "exercises/09_strings/strings4.rs" },
81+
{ name = "strings4_sol", path = "solutions/09_strings/strings4.rs" },
82+
{ name = "modules1", path = "exercises/10_modules/modules1.rs" },
83+
{ name = "modules1_sol", path = "solutions/10_modules/modules1.rs" },
84+
{ name = "modules2", path = "exercises/10_modules/modules2.rs" },
85+
{ name = "modules2_sol", path = "solutions/10_modules/modules2.rs" },
86+
{ name = "modules3", path = "exercises/10_modules/modules3.rs" },
87+
{ name = "modules3_sol", path = "solutions/10_modules/modules3.rs" },
88+
{ name = "hashmaps1", path = "exercises/11_hashmaps/hashmaps1.rs" },
89+
{ name = "hashmaps1_sol", path = "solutions/11_hashmaps/hashmaps1.rs" },
90+
{ name = "hashmaps2", path = "exercises/11_hashmaps/hashmaps2.rs" },
91+
{ name = "hashmaps2_sol", path = "solutions/11_hashmaps/hashmaps2.rs" },
92+
{ name = "hashmaps3", path = "exercises/11_hashmaps/hashmaps3.rs" },
93+
{ name = "hashmaps3_sol", path = "solutions/11_hashmaps/hashmaps3.rs" },
94+
{ name = "quiz2", path = "exercises/quizzes/quiz2.rs" },
95+
{ name = "quiz2_sol", path = "solutions/quizzes/quiz2.rs" },
96+
{ name = "options1", path = "exercises/12_options/options1.rs" },
97+
{ name = "options1_sol", path = "solutions/12_options/options1.rs" },
98+
{ name = "options2", path = "exercises/12_options/options2.rs" },
99+
{ name = "options2_sol", path = "solutions/12_options/options2.rs" },
100+
{ name = "options3", path = "exercises/12_options/options3.rs" },
101+
{ name = "options3_sol", path = "solutions/12_options/options3.rs" },
102+
{ name = "errors1", path = "exercises/13_error_handling/errors1.rs" },
103+
{ name = "errors1_sol", path = "solutions/13_error_handling/errors1.rs" },
104+
{ name = "errors2", path = "exercises/13_error_handling/errors2.rs" },
105+
{ name = "errors2_sol", path = "solutions/13_error_handling/errors2.rs" },
106+
{ name = "errors3", path = "exercises/13_error_handling/errors3.rs" },
107+
{ name = "errors3_sol", path = "solutions/13_error_handling/errors3.rs" },
108+
{ name = "errors4", path = "exercises/13_error_handling/errors4.rs" },
109+
{ name = "errors4_sol", path = "solutions/13_error_handling/errors4.rs" },
110+
{ name = "errors5", path = "exercises/13_error_handling/errors5.rs" },
111+
{ name = "errors5_sol", path = "solutions/13_error_handling/errors5.rs" },
112+
{ name = "errors6", path = "exercises/13_error_handling/errors6.rs" },
113+
{ name = "errors6_sol", path = "solutions/13_error_handling/errors6.rs" },
114+
{ name = "generics1", path = "exercises/14_generics/generics1.rs" },
115+
{ name = "generics1_sol", path = "solutions/14_generics/generics1.rs" },
116+
{ name = "generics2", path = "exercises/14_generics/generics2.rs" },
117+
{ name = "generics2_sol", path = "solutions/14_generics/generics2.rs" },
118+
{ name = "traits1", path = "exercises/15_traits/traits1.rs" },
119+
{ name = "traits1_sol", path = "solutions/15_traits/traits1.rs" },
120+
{ name = "traits2", path = "exercises/15_traits/traits2.rs" },
121+
{ name = "traits2_sol", path = "solutions/15_traits/traits2.rs" },
122+
{ name = "traits3", path = "exercises/15_traits/traits3.rs" },
123+
{ name = "traits3_sol", path = "solutions/15_traits/traits3.rs" },
124+
{ name = "traits4", path = "exercises/15_traits/traits4.rs" },
125+
{ name = "traits4_sol", path = "solutions/15_traits/traits4.rs" },
126+
{ name = "traits5", path = "exercises/15_traits/traits5.rs" },
127+
{ name = "traits5_sol", path = "solutions/15_traits/traits5.rs" },
128+
{ name = "quiz3", path = "exercises/quizzes/quiz3.rs" },
129+
{ name = "quiz3_sol", path = "solutions/quizzes/quiz3.rs" },
130+
{ name = "lifetimes1", path = "exercises/16_lifetimes/lifetimes1.rs" },
131+
{ name = "lifetimes1_sol", path = "solutions/16_lifetimes/lifetimes1.rs" },
132+
{ name = "lifetimes2", path = "exercises/16_lifetimes/lifetimes2.rs" },
133+
{ name = "lifetimes2_sol", path = "solutions/16_lifetimes/lifetimes2.rs" },
134+
{ name = "lifetimes3", path = "exercises/16_lifetimes/lifetimes3.rs" },
135+
{ name = "lifetimes3_sol", path = "solutions/16_lifetimes/lifetimes3.rs" },
136+
{ name = "tests1", path = "exercises/17_tests/tests1.rs" },
137+
{ name = "tests1_sol", path = "solutions/17_tests/tests1.rs" },
138+
{ name = "tests2", path = "exercises/17_tests/tests2.rs" },
139+
{ name = "tests2_sol", path = "solutions/17_tests/tests2.rs" },
140+
{ name = "tests3", path = "exercises/17_tests/tests3.rs" },
141+
{ name = "tests3_sol", path = "solutions/17_tests/tests3.rs" },
142+
{ name = "iterators1", path = "exercises/18_iterators/iterators1.rs" },
143+
{ name = "iterators1_sol", path = "solutions/18_iterators/iterators1.rs" },
144+
{ name = "iterators2", path = "exercises/18_iterators/iterators2.rs" },
145+
{ name = "iterators2_sol", path = "solutions/18_iterators/iterators2.rs" },
146+
{ name = "iterators3", path = "exercises/18_iterators/iterators3.rs" },
147+
{ name = "iterators3_sol", path = "solutions/18_iterators/iterators3.rs" },
148+
{ name = "iterators4", path = "exercises/18_iterators/iterators4.rs" },
149+
{ name = "iterators4_sol", path = "solutions/18_iterators/iterators4.rs" },
150+
{ name = "iterators5", path = "exercises/18_iterators/iterators5.rs" },
151+
{ name = "iterators5_sol", path = "solutions/18_iterators/iterators5.rs" },
152+
{ name = "box1", path = "exercises/19_smart_pointers/box1.rs" },
153+
{ name = "box1_sol", path = "solutions/19_smart_pointers/box1.rs" },
154+
{ name = "rc1", path = "exercises/19_smart_pointers/rc1.rs" },
155+
{ name = "rc1_sol", path = "solutions/19_smart_pointers/rc1.rs" },
156+
{ name = "arc1", path = "exercises/19_smart_pointers/arc1.rs" },
157+
{ name = "arc1_sol", path = "solutions/19_smart_pointers/arc1.rs" },
158+
{ name = "cow1", path = "exercises/19_smart_pointers/cow1.rs" },
159+
{ name = "cow1_sol", path = "solutions/19_smart_pointers/cow1.rs" },
160+
{ name = "threads1", path = "exercises/20_threads/threads1.rs" },
161+
{ name = "threads1_sol", path = "solutions/20_threads/threads1.rs" },
162+
{ name = "threads2", path = "exercises/20_threads/threads2.rs" },
163+
{ name = "threads2_sol", path = "solutions/20_threads/threads2.rs" },
164+
{ name = "threads3", path = "exercises/20_threads/threads3.rs" },
165+
{ name = "threads3_sol", path = "solutions/20_threads/threads3.rs" },
166+
{ name = "macros1", path = "exercises/21_macros/macros1.rs" },
167+
{ name = "macros1_sol", path = "solutions/21_macros/macros1.rs" },
168+
{ name = "macros2", path = "exercises/21_macros/macros2.rs" },
169+
{ name = "macros2_sol", path = "solutions/21_macros/macros2.rs" },
170+
{ name = "macros3", path = "exercises/21_macros/macros3.rs" },
171+
{ name = "macros3_sol", path = "solutions/21_macros/macros3.rs" },
172+
{ name = "macros4", path = "exercises/21_macros/macros4.rs" },
173+
{ name = "macros4_sol", path = "solutions/21_macros/macros4.rs" },
174+
{ name = "clippy1", path = "exercises/22_clippy/clippy1.rs" },
175+
{ name = "clippy1_sol", path = "solutions/22_clippy/clippy1.rs" },
176+
{ name = "clippy2", path = "exercises/22_clippy/clippy2.rs" },
177+
{ name = "clippy2_sol", path = "solutions/22_clippy/clippy2.rs" },
178+
{ name = "clippy3", path = "exercises/22_clippy/clippy3.rs" },
179+
{ name = "clippy3_sol", path = "solutions/22_clippy/clippy3.rs" },
180+
{ name = "using_as", path = "exercises/23_conversions/using_as.rs" },
181+
{ name = "using_as_sol", path = "solutions/23_conversions/using_as.rs" },
182+
{ name = "from_into", path = "exercises/23_conversions/from_into.rs" },
183+
{ name = "from_into_sol", path = "solutions/23_conversions/from_into.rs" },
184+
{ name = "from_str", path = "exercises/23_conversions/from_str.rs" },
185+
{ name = "from_str_sol", path = "solutions/23_conversions/from_str.rs" },
186+
{ name = "try_from_into", path = "exercises/23_conversions/try_from_into.rs" },
187+
{ name = "try_from_into_sol", path = "solutions/23_conversions/try_from_into.rs" },
188+
{ name = "as_ref_mut", path = "exercises/23_conversions/as_ref_mut.rs" },
189+
{ name = "as_ref_mut_sol", path = "solutions/23_conversions/as_ref_mut.rs" },
190+
]
191+
192+
[package]
193+
name = "exercises"
194+
edition = "2021"
195+
# Don't publish the exercises on crates.io!
196+
publish = false
197+
198+
[profile.release]
199+
panic = "abort"
200+
201+
[profile.dev]
202+
panic = "abort"
203+
204+
[lints.rust]
205+
# You shouldn't write unsafe code in Rustlings!
206+
unsafe_code = "forbid"
207+
# You don't need unstable features in Rustlings and shouldn't rely on them while learning Rust.
208+
unstable_features = "forbid"
209+
# Dead code warnings can't be avoided in some exercises and might distract while learning.
210+
dead_code = "allow"
211+
212+
[lints.clippy]
213+
# You forgot a `todo!()`!
214+
todo = "forbid"
215+
# This can only happen by mistake in Rustlings.
216+
empty_loop = "forbid"
217+
# No infinite loops are needed in Rustlings.
218+
infinite_loop = "deny"
219+
# You shouldn't leak memory while still learning Rust!
220+
mem_forget = "deny"
221+
# Currently, there are no disallowed methods. This line avoids problems when developing Rustlings.
222+
disallowed_methods = "allow"

exercises/00_intro/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Intro
2+
3+
Rust uses the `print!` and `println!` macros to print text to the console.
4+
5+
## Further information
6+
7+
- [Hello World](https://doc.rust-lang.org/rust-by-example/hello.html)
8+
- [Formatted print](https://doc.rust-lang.org/rust-by-example/hello/print.html)

exercises/00_intro/intro1.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// TODO: We sometimes encourage you to keep trying things on a given exercise
2+
// even after you already figured it out. If you got everything working and feel
3+
// ready for the next exercise, enter `n` in the terminal.
4+
//
5+
// The exercise file will be reloaded when you change one of the lines below!
6+
// Try adding a new `println!` and check the updated output in the terminal.
7+
8+
fn main() {
9+
println!(r#" Welcome to... "#);
10+
println!(r#" _ _ _ "#);
11+
println!(r#" _ __ _ _ ___| |_| (_)_ __ __ _ ___ "#);
12+
println!(r#" | '__| | | / __| __| | | '_ \ / _` / __| "#);
13+
println!(r#" | | | |_| \__ \ |_| | | | | | (_| \__ \ "#);
14+
println!(r#" |_| \__,_|___/\__|_|_|_| |_|\__, |___/ "#);
15+
println!(r#" |___/ "#);
16+
println!();
17+
println!("This exercise compiles successfully. The remaining exercises contain a compiler");
18+
println!("or logic error. The central concept behind Rustlings is to fix these errors and");
19+
println!("solve the exercises. Good luck!");
20+
println!();
21+
println!("The file of this exercise is `exercises/00_intro/intro1.rs`. Have a look!");
22+
println!("The current exercise path will be always shown under the progress bar.");
23+
println!("You can click on the path to open the exercise file in your editor.");
24+
}

exercises/00_intro/intro2.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
// TODO: Fix the code to print "Hello world!".
3+
println!("Hello world!");
4+
}

exercises/01_variables/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Variables
2+
3+
In Rust, variables are immutable by default.
4+
When a variable is immutable, once a value is bound to a name, you can’t change that value.
5+
You can make them mutable by adding `mut` in front of the variable name.
6+
7+
## Further information
8+
9+
- [Variables and Mutability](https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html)

exercises/01_variables/variables1.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn main() {
2+
// TODO: Add the missing keyword.
3+
let x = 5;
4+
5+
println!("x has the value {x}");
6+
}

exercises/01_variables/variables2.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn main() {
2+
// TODO: Change the line below to fix the compiler error.
3+
let x = 10;
4+
5+
if x == 10 {
6+
println!("x is ten!");
7+
} else {
8+
println!("x is not ten!");
9+
}
10+
}

exercises/01_variables/variables3.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn main() {
2+
// TODO: Change the line below to fix the compiler error.
3+
let x: i32 = 10;
4+
5+
println!("Number {x}");
6+
}

exercises/01_variables/variables4.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// TODO: Fix the compiler error.
2+
fn main() {
3+
let mut x = 3;
4+
println!("Number {x}");
5+
6+
x = 5; // Don't change this line
7+
println!("Number {x}");
8+
}

exercises/01_variables/variables5.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn main() {
2+
let number = "T-H-R-E-E"; // Don't change this line
3+
println!("Spell a number: {}", number);
4+
5+
// TODO: Fix the compiler error by changing the line below without renaming the variable.
6+
let number = 3;
7+
println!("Number plus two is: {}", number + 2);
8+
}

exercises/01_variables/variables6.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// TODO: Change the line below to fix the compiler error.
2+
const NUMBER: i32 = 3;
3+
4+
fn main() {
5+
println!("Number: {NUMBER}");
6+
}

exercises/02_functions/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Functions
2+
3+
Here, you'll learn how to write functions and how the Rust compiler can help you debug errors even
4+
in more complex code.
5+
6+
## Further information
7+
8+
- [How Functions Work](https://doc.rust-lang.org/book/ch03-03-how-functions-work.html)

exercises/02_functions/functions1.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// TODO: Add some function with the name `call_me` without arguments or a return value.
2+
fn call_me() {
3+
println!("Hello, world!");
4+
}
5+
6+
fn main() {
7+
call_me(); // Don't change this line
8+
}

exercises/02_functions/functions2.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// TODO: Add the missing type of the argument `num` after the colon `:`.
2+
fn call_me(num: i32) {
3+
for i in 0..num {
4+
println!("Ring! Call number {}", i + 1);
5+
}
6+
}
7+
8+
fn main() {
9+
call_me(3);
10+
}

exercises/02_functions/functions3.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn call_me(num: u8) {
2+
for i in 0..num {
3+
println!("Ring! Call number {}", i + 1);
4+
}
5+
}
6+
7+
fn main() {
8+
// TODO: Fix the function call.
9+
call_me(3);
10+
}

0 commit comments

Comments
 (0)