expression
Rust operator precedence: group expressions clearly
Precedence controls how expressions group: multiplication, division and remainder bind more tightly than addition and subtraction. Parentheses make a different grouping explicit. Logical AND binds more tightly than logical OR. Expected output (not executed): 16 36 Why: The first expression multiplies only extra; the second multiplies the sum. Common mistake: Precedence is grouping, not a universal statement of operand evaluation order. Comparisons cannot be chained without explicit grouping and suitable types.
Formal Syntax & Structure
rust syntaxrust
(a + b) * cWorking Example
Example Snippetrust
fn main() { let base = 10; let extra = 2; println!("{}", base + extra * 3); println!("{}", (base + extra) * 3);}