Skip to content

Commit 59d6b85

Browse files
committed
move_semantics5: Move main to the end
1 parent e512928 commit 59d6b85

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

exercises/06_move_semantics/move_semantics5.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@
33
// TODO: Fix the compiler errors without changing anything except adding or
44
// removing references (the character `&`).
55

6-
fn main() {
7-
let data = "Rust is great!".to_string();
8-
9-
get_char(data);
10-
11-
string_uppercase(&data);
12-
}
13-
146
// Shouldn't take ownership
157
fn get_char(data: String) -> char {
168
data.chars().last().unwrap()
@@ -22,3 +14,11 @@ fn string_uppercase(mut data: &String) {
2214

2315
println!("{data}");
2416
}
17+
18+
fn main() {
19+
let data = "Rust is great!".to_string();
20+
21+
get_char(data);
22+
23+
string_uppercase(&data);
24+
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
#![allow(clippy::ptr_arg)]
22

3-
fn main() {
4-
let data = "Rust is great!".to_string();
5-
6-
get_char(&data);
7-
8-
string_uppercase(data);
9-
}
10-
113
// Borrows instead of taking ownership.
124
// It is recommended to use `&str` instead of `&String` here. But this is
135
// enough for now because we didn't handle strings yet.
@@ -21,3 +13,11 @@ fn string_uppercase(mut data: String) {
2113

2214
println!("{data}");
2315
}
16+
17+
fn main() {
18+
let data = "Rust is great!".to_string();
19+
20+
get_char(&data);
21+
22+
string_uppercase(data);
23+
}

0 commit comments

Comments
 (0)