Control Flow


  • Blocks have value

  • Operator precedence table is in the reference manual. 18 levels. Left associativity. Left-to-right evaluation?

  • Conversion is mostly explicit through as. Only conversions that are "safe" work (where safe has a somewhat non-intuitive definition)

  • Reference magic happens

    • Auto dereference in certain situations as discussed earlier
    • Auto reference conversions in certain situations, e.g. String, Vec, Box

Expressions and Control Flow

  • In Rust, some of what we would normally do with control flow is done with simple expressions. This is part of Rust's functional-language heritage

    • if is an expression type
    • "method" chaining is a standard mechanism

"Method" Chaining

Explicit Control Flow

  • if-else

  • if let, while let

  • match

  • while

  • loop

  • for and iterators

Last modified: Thursday, 15 April 2021, 12:54 AM