Expressions

The instructions that tell the computer to do something in a Rust program are almost all expressions. An expression tells the computer how to compute a particular value, and produces that value as its result. In math, 2 + 2 is an expression with a resulting value of 4. Similarly, (2 + 2) - 1 is an expression with a resulting value of 3, which is itself made up of an addition expression and a subtraction expression. In Rust, the same basic idea applies: expressions tell the computer how to find a value, and they can be combined together, because using an expression that produces a value has the same result as using that value directly, just as writing (2 + 2) - 1 has the same result as writing 4 - 1.

Not all expressions in Rust look like math, though. Rust is a programming language, not just a calculator. It's the idea of expressions, which combine values to produce new values, that matters.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.141.75