operator

Rust =: replace an existing value

Assignment stores a value in an existing destination. Reassigning an initialized local binding requires it to allow mutation. The assignment expression yields unit `()`. Expected output (not executed): ready () Why: The binding now contains ready; assignment itself does not return that string. Common mistake: A `let` declaration creates a binding; `=` alone assigns. Do not use chained assignment to distribute a numeric value. Advanced connection: For non-Copy values assignment may move ownership and drop the replaced value.

Formal Syntax & Structure

rust syntaxrust
place = value

Working Example

Example Snippetrust
fn main() {    let mut status = "pending";    assert_eq!(status, "pending");    let result = { status = "ready" };    println!("{status}");    println!("{result:?}");}
Rust Reference