# Rust: error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable

**Code:** `E0596: cannot borrow as mutable, as it is not declared as mutable` · **Category:** Rust · **Seen on:** Rust

You called a `&mut` method (or took `&mut`) on a binding/reference that isn't mutable.

## Meaning

Add `mut` to the binding (`let mut v = Vec::new();`), take `&mut` parameters (`fn f(v: &mut Vec<i32>)`), and make `self` `&mut self` for mutating methods. Through `&T` you can't mutate — use `&mut T`, `RefCell`, or `Cell`.

## Common causes

- `let v = Vec::new(); v.push(1);`
- Method takes `&self` but mutates
- Parameter is `&T` not `&mut T`
- Closure capturing a variable mutably without `mut`
- Iterating with `iter()` then mutating (use `iter_mut()`)

## Quick fix

1. Declare `let mut`
2. Change signature to `&mut self`/`&mut T`
3. Use `iter_mut()`; consider `RefCell` for interior mutability

## Detailed fix by platform

### Rust

1. `fn add(&mut self, x: i32) { self.items.push(x); }`

## How to diagnose

1. **Binding** — mut?
2. **Signature** — &mut?
3. **Iterator** — iter_mut?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/rust/e0596-cannot-borrow-as-mutable-not-declared-mut)
