Salut, sur cette page https://www.tutorialspoint.com/rust/rust_borrowing.htm
on peut lire : Illustration: Mutating an integer reference
fn add_one(e: &mut i32) {
*e+= 1;
}
fn main() {
let mut i = 3;
add_one(&mut i);
println!("{}", i);
}
Illustration: Mutating a string reference
fn main() {
let mut name:String = String::from("TutorialsPoint");
display(&mut name);
//pass a mutable reference of name
println!("The value of name after modification is:{}",name);
}
fn display(param_name:&mut String){
println!("param_name value is :{}",param_name);
param_name.push_str(" Rocks");
//Modify the actual string,name
}
pourquoi ne note t on pas
fn display(param_name:&mut String){
println!("param_name value is :{}",*param_name);
+0
-0