diff options
| author | anand <anand.panchdhari@gmail.com> | 2025-11-19 14:35:50 +0530 |
|---|---|---|
| committer | anand <anand.panchdhari@gmail.com> | 2025-11-19 14:35:50 +0530 |
| commit | f8d94cce2a21067d666f65d23d591f0f40cf6c36 (patch) | |
| tree | 773c005674c1b21e3ef68a39feabb87aa2eaa305 /exercises/06_move_semantics/move_semantics5.rs | |
| parent | 8597b29e143cdeae50eafae06e0d8ed900b25295 (diff) | |
Finished vecs and move semantics
Diffstat (limited to 'exercises/06_move_semantics/move_semantics5.rs')
| -rw-r--r-- | exercises/06_move_semantics/move_semantics5.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/exercises/06_move_semantics/move_semantics5.rs b/exercises/06_move_semantics/move_semantics5.rs index cd0dafd..78d8c77 100644 --- a/exercises/06_move_semantics/move_semantics5.rs +++ b/exercises/06_move_semantics/move_semantics5.rs @@ -4,12 +4,12 @@ // removing references (the character `&`). // Shouldn't take ownership -fn get_char(data: String) -> char { +fn get_char(data: &String) -> char { data.chars().last().unwrap() } // Should take ownership -fn string_uppercase(mut data: &String) { +fn string_uppercase(mut data: String) { data = data.to_uppercase(); println!("{data}"); @@ -18,7 +18,7 @@ fn string_uppercase(mut data: &String) { fn main() { let data = "Rust is great!".to_string(); - get_char(data); + get_char(&data); - string_uppercase(&data); + string_uppercase(data); } |
