RustCurious.com
Rust explained carefully.

Lesson 11

Reborrowing and Rust's Invisible Lifetimes

We dig further into reborrowing, to learn about the invisible lifetime information attached to every reference type.

Coding Practice

Example: Move vs Reborrow

Open in playground

// https://rustcurious.com/11

// Example: Move vs Reborrow
//
// Add an explicit type for `c` to change the
// assignment from a move into a reborrow.
//
// Alternatives to try:
//
//     let c: &mut i32 = b;
//     let c: &mut _ = b;
//     let c = b as &mut _;
//     let c = &mut *b;

fn main() {
    let mut a = 10;
    let b = &mut a;
    *b += 1;
    let c = b;
    *c += 1;

    *b += 1;

    println!("{}", a);
}