There are no errors here, and I'm a bit curious. When I call a function terima_nilai
into a variable pengguna
and then provide a String
as a parameter to be passed to the function terima_nilai
, am I also performing a move
on the variable to terima_nilai
?
I don't quite understand because the parameter in the function called on that variable is not like the original value of the variable, its only parameter for terima_nilai
.
struct User {
nama_tanaman: String,
nama_latin: String,
tahun_penemuan: i32,
}
fn terima_nilai (nama_tanaman: String, nama_latin: String) -> User {
User {
nama_tanaman,
nama_latin,
tahun_penemuan: 1000,
}
}
fn main () {
// Is this transfer my ownership for pengguna to fn terima_nilai?
// Then fn terima_nilai transfer back the ownership to pengguna?
let pengguna = terima_nilai(
String::from("Wortel"),
String::from("Daucus carota"),
);
}