Current move_semantics1 exercice implements main as follows :
fn main() {
let arr0 = ArrayTrait::new();
let arr1 = fill_arr(arr0);
// This is just a print statement for arrays.
arr1.clone().print();
//TODO fix the error here without modifying this line.
arr1.append(88);
arr1.clone().print();
}
Nevertheless, using clone() in the last line is not necessary, as ownership of arr1 can be given to print method without issue because it is never used after that. It would avoid unnecessary clone call to replace main with :
fn main() {
let arr0 = ArrayTrait::new();
let arr1 = fill_arr(arr0);
// This is just a print statement for arrays.
arr1.clone().print();
//TODO fix the error here without modifying this line.
arr1.append(88);
arr1.print();
}
Current move_semantics1 exercice implements
main
as follows :Nevertheless, using
clone()
in the last line is not necessary, as ownership ofarr1
can be given toprint
method without issue because it is never used after that. It would avoid unnecessary clone call to replacemain
with :