Complete the code to create a mutable reference to the variable num.
let mut num = 5; let num_ref = &[1] num;
To create a mutable reference in Rust, you use &mut before the variable name.
Complete the code to change the value through the mutable reference num_ref.
let mut num = 10; let num_ref = &mut num; *[1] = 20;
To change the value through a mutable reference, you dereference it with * and assign a new value.
Fix the error in the code by completing the blank to allow mutable borrowing.
let mut value = 15; let ref2 = &[1] value; *ref2 += 1; println!("Value: {}", *ref2);
To borrow a variable mutably, you must use &mut. This allows changing the value through the reference.
Fill both blanks to create a mutable reference and modify the value through it.
let mut count = 0; let count_ref = &[1] count; *count_ref [2] 5;
The first blank needs mut to create a mutable reference. The second blank uses += to add 5 to the value.
Fill all three blanks to create a mutable reference, modify the value, and print it.
let mut score = 10; let score_ref = &[1] score; *score_ref [2] 15; println!("Score: {}", [3]);
Use mut to create a mutable reference. Use += to add 15 to the value. Print the updated value by dereferencing the mutable reference with *score_ref.
