From 59d6b852afd81385020f2b59ab95c85af6229763 Mon Sep 17 00:00:00 2001 From: mo8it Date: Wed, 10 Jul 2024 13:47:33 +0200 Subject: [PATCH] move_semantics5: Move `main` to the end --- exercises/06_move_semantics/move_semantics5.rs | 16 ++++++++-------- solutions/06_move_semantics/move_semantics5.rs | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/exercises/06_move_semantics/move_semantics5.rs b/exercises/06_move_semantics/move_semantics5.rs index fc593387..cd0dafd0 100644 --- a/exercises/06_move_semantics/move_semantics5.rs +++ b/exercises/06_move_semantics/move_semantics5.rs @@ -3,14 +3,6 @@ // TODO: Fix the compiler errors without changing anything except adding or // removing references (the character `&`). -fn main() { - let data = "Rust is great!".to_string(); - - get_char(data); - - string_uppercase(&data); -} - // Shouldn't take ownership fn get_char(data: String) -> char { data.chars().last().unwrap() @@ -22,3 +14,11 @@ fn string_uppercase(mut data: &String) { println!("{data}"); } + +fn main() { + let data = "Rust is great!".to_string(); + + get_char(data); + + string_uppercase(&data); +} diff --git a/solutions/06_move_semantics/move_semantics5.rs b/solutions/06_move_semantics/move_semantics5.rs index 678ec97b..1410e913 100644 --- a/solutions/06_move_semantics/move_semantics5.rs +++ b/solutions/06_move_semantics/move_semantics5.rs @@ -1,13 +1,5 @@ #![allow(clippy::ptr_arg)] -fn main() { - let data = "Rust is great!".to_string(); - - get_char(&data); - - string_uppercase(data); -} - // Borrows instead of taking ownership. // It is recommended to use `&str` instead of `&String` here. But this is // enough for now because we didn't handle strings yet. @@ -21,3 +13,11 @@ fn string_uppercase(mut data: String) { println!("{data}"); } + +fn main() { + let data = "Rust is great!".to_string(); + + get_char(&data); + + string_uppercase(data); +}