# Rust: error[E0384]: cannot assign twice to immutable variable `x`

**Code:** `E0384: cannot assign twice to immutable variable` · **Category:** Rust · **Seen on:** Rust

You reassigned a variable declared without `mut`.

## Meaning

Declare it `let mut x = ...` if reassignment is intended, or shadow it (`let x = x + 1;`) which creates a new binding. Function parameters are immutable too (`mut param`). For loops with counters use `let mut`.

## Common causes

- Missing `mut` on the variable
- Reassigning function parameters
- Loop counter immutable
- Assigning in a closure without `mut` capture
- Struct field assignment through immutable binding

## Quick fix

1. `let mut x = 5;`
2. Shadow: `let x = x + 1;`
3. `fn f(mut x: i32)` for parameters

## Detailed fix by platform

### Rust

1. `let mut count = 0; count += 1;`

## How to diagnose

1. **Binding** — mut?
2. **Intent** — Reassign or shadow?
3. **Param** — mut?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/rust/e0384-cannot-assign-twice-to-immutable-variable)
