Does the mutable variable is a mutable reference in rust?

I'm pretty thank you for your helpful and timely reply.

I wrote this test code originally because when reading the official Rust book at References and Borrowing - The Rust Programming Language , in the Mutable References section, it mentions a rule:

if you have a mutable reference to a value, you can have no other references to that value

After my research, this rule can be reasonably translated as:

The lifetime of an mutable reference can't overlap with the lifetime of any other reference(& and &mut) to the same variable

And the reference lifetime here is: the time from when the reference is introduced to the last time it is used.

We know that the rule is mentioned in the mutable reference section because mutable references modify the data content, and overlapping lifetimes with other references may cause data races.

When I thought of this, I realized that the above rule did not cover all cases because it only involved references and did not involve variables. for example, what happens if the variable referenced by a mutable reference attempts to modify the content during the lifetime of the mutable reference ?

Therefore, I wrote this test code:

fn main() {
   let mut s1 = String::from("hello");

   let r2 = &mut s1;

   s1.push_str(",world");

   println!("r3: {}", r2);
}

When I saw the compilation error: "second mutable borrow occurs here" at s1.push_str(",world");
I thought that s1 was also a mutable reference, and a borrow occurred here. Upon your reminder,
I checked the definition of the push_str method and found that it's first parameter is &mut self , and
only then did I realize that it created a second mutable reference to the variable s1 within the lifetime
of reference r2 , causing the compilation error.
therefore the above test code did not achieve my goal of whether it is allowed to modify the data content through the variable during the lifetime of a mutable reference.

So I tried the following test code:

fn main() {
    let mut s1 = String::from("hello");

    let r2 = &mut s1;

    s1 = String::from(",world");

    println!("r3: {}", r2);
}

It's also generated a compilation error:

error[E0506]: cannot assign to `s1` because it is borrowed
 --> src/main.rs:6:5
  |
4 |     let r2 = &mut s1;
  |              ------- borrow of `s1` occurs here
5 |
6 |     s1 = String::from(",world");
  |     ^^ assignment to borrowed `s1` occurs here
7 |
8 |     println!("r3: {}", r2);
  |                        -- borrow later used here

so it seems that during the lifetime of a mutable reference not only can there be no other references to the same variable as said in the rule, but also the data content can't be modified through the variable.

Then I wonder if it is possible to modify the data content through the variable during the lifetime of a shared reference(&), so I wrote the following test code:

fn main() {
    let mut s1 = String::from("hello");

    let r2 = &s1;

    s1 = String::from(",world");

    println!("r3: {}", r2);
}

The same compilation error occurred:

error[E0506]: cannot assign to `s1` because it is borrowed
 --> src/main.rs:6:5
  |
4 |     let r2 = &s1;
  |              --- borrow of `s1` occurs here
5 |
6 |     s1 = String::from(",world");
  |     ^^ assignment to borrowed `s1` occurs here
7 |
8 |     println!("r3: {}", r2);
  |                        -- borrow later used here

For more information about this error, try `rustc --explain E0506`.

After this, I feel that the rule could be modified to : during the lifetime of a mutable reference, there should be no other references to the same variable(both & and &mut) , and the variable's data content can't be modified through it's variable. Similarly, during the lifetime of an immutable reference, the variable's data content can't be modified through it's variable also.

the interesting term you mentioned exclusive action I guess includes: mutable borrowing , change the data content through the variable, Move (move ownership to another variable or out of the current scope)

so I guess the modified rule above can be changed again as: either borrowed references(&) or mutable references existed before the exclusive action cannot be used afterwords.

Do you think this modified rule is accurate ? thank you.