Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

mutable reference

A reference that lets you change the value it points to.

A mutable reference &mut T allows changing the referent; only one may exist at a time.

Loading interactive…

Examples

  • fn add_point(score: &mut u32) { *score += 1; } called as add_point(&mut score) changes main's own variable.

  • Two &mut x borrows in use at the same time are rejected with E0499.

Read the full section →