Question about an "obscure" comment in the Reference (mut VS const)

⚓ Rust    📅 2026-01-28    👤 surdeus    👁️ 1      

surdeus

In this rust doc: Statements - The Rust Reference

I can read "let (mut v, w) = (vec![1, 2, 3], 42); // The bindings may be mut or const"

The alternative of "let mut" is just "let" ("let const" is a compilation error).

In the comment they use "const" as an alternative to "mut" (which hold true in the context of raw pointers).

But, again in the context of let, are they using "const" in this sentence because there is no alternative (the sentence couldn't simply end in "or" like this: "The bindings may be mut or") or, deep down the language, a "let" is in reality a "let const"?

What I'm really asking is whether at some level of the compiler's internal representation, there might actually be an explicit "const" marker that gets added to non-mut bindings. What appears as just "let" in source code could internally be represented with an explicit immutability marker (const).

7 posts - 5 participants

Read full topic

🏷️ Rust_feed