Language / Expression statements

Expression statements

Many expressions can appear as standalone statements when followed by ; (assignment, calls, ++/--, and other “statement-like” expressions).

Full reference: flow expression statements.

Notes#

Example: assignment + increment#

fn main () -> int {
  let mut x: int = 0;
  x += 1;
  ++x;
  return x;
}

See also#

Source repository · Edit this page · View Markdown

Quick links

Type to search across the site. Use the up and down arrow keys to choose a result, Enter to open it, and Escape to close.