2024-07-04 12:38:35 +01:00
|
|
|
#![allow(clippy::ptr_arg)]
|
|
|
|
|
2024-06-21 17:29:00 +01:00
|
|
|
// TODO: Fix the compiler errors without changing anything except adding or
|
|
|
|
// removing references (the character `&`).
|
2021-05-17 13:10:40 +01:00
|
|
|
|
2024-06-21 17:14:19 +01:00
|
|
|
// Shouldn't take ownership
|
|
|
|
fn get_char(data: String) -> char {
|
|
|
|
data.chars().last().unwrap()
|
2024-04-17 22:34:27 +01:00
|
|
|
}
|
|
|
|
|
2024-06-21 17:14:19 +01:00
|
|
|
// Should take ownership
|
|
|
|
fn string_uppercase(mut data: &String) {
|
2024-07-04 14:18:09 +01:00
|
|
|
data = data.to_uppercase();
|
2024-04-17 22:34:27 +01:00
|
|
|
|
2024-06-21 17:14:19 +01:00
|
|
|
println!("{data}");
|
2021-05-17 13:10:40 +01:00
|
|
|
}
|
2024-07-10 12:47:33 +01:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let data = "Rust is great!".to_string();
|
|
|
|
|
|
|
|
get_char(data);
|
|
|
|
|
|
|
|
string_uppercase(&data);
|
|
|
|
}
|