Learn Before
Code
Example of Mutable Reference - Rust Programming
fn main() { let mut s1 = String::from("hello"); // Pass a mutable reference to the function change(&mut s1); println!("{}", s1); } fn change(s: &mut String) { s.push_str(", world"); } // s goes out of scope, but since // it's a mutable reference, nothing is freed
0
1
Updated 2023-04-19
Tags
Object-Oriented Programming
Programming Language Paradigms
General programming languages
Computing Sciences