blob: 6cf30ae3be1a5e068e6bce1ee4c5c2c10eecc277 [file] [log] [blame] [view]
r[expr.return]
# `return` expressions
r[expr.return.syntax]
> **<sup>Syntax</sup>**\
> _ReturnExpression_ :\
> &nbsp;&nbsp; `return` [_Expression_]<sup>?</sup>
r[expr.return.intro]
Return expressions are denoted with the keyword `return`.
r[expr.return.behavior]
Evaluating a `return` expression moves its argument into the designated output location for the current function call, destroys the current function activation frame, and transfers control to the caller frame.
An example of a `return` expression:
```rust
fn max(a: i32, b: i32) -> i32 {
if a > b {
return a;
}
return b;
}
```
[_Expression_]: ../expressions.md