[Beginner] Systemising operations on variables for learning purposes
⚓ Rust 📅 2026-06-10 👤 surdeus 👁️ 2I am refreshing rust after some time doing other things and it occurred to me that having a table of operations on variables could be useful?
My idea (before learning about interior mutability) was this table below, which I asked a chatbot to generate for me:
| Operation | Immutable binding (let) |
Mutable binding (let mut) |
|---|---|---|
0) Shadow/re-declare (let x = ...) |
Y | Y |
1) Reassign (x = ...) |
N | Y |
2) Update contents (push, insert, etc.) |
N | Y |
My idea was that, in general, it may be useful to separate what we do with variables as:
- Re-Declare as in
let a_gain=5; let a_gain=6; - Re-Assign:
a_gain += 1ora_gain=6 - Update contents
a_gain.push_str("more")
I suspect this is all quite wrong or at least incomplete, and am posting here for some corrections or suggestions, or possibly some extension of the table.
It was fun to think about this though.
2 posts - 2 participants
🏷️ Rust_feed