Skip to content

Moved grouped expressions to its own page #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- [Path expressions](expressions/path-expr.md)
- [Block expressions](expressions/block-expr.md)
- [Operator expressions](expressions/operator-expr.md)
- [Grouped expressions](expressions/grouped-expr.md)
- [Array and index expressions](expressions/array-expr.md)
- [Tuple and index expressions](expressions/tuple-expr.md)
- [Struct expressions](expressions/struct-expr.md)
Expand Down
2 changes: 1 addition & 1 deletion src/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ exist in `core::ops` and `core::cmp` with the same names.
[closure expressions]: expressions/closure-expr.html
[enum variant]: expressions/enum-variant-expr.html
[field]: expressions/field-expr.html
[grouped]: expressions/grouped-expr.html
[literals]: expressions/literal-expr.html
[match]: expressions/match-expr.html
[method-call]: expressions/method-call-expr.html
Expand All @@ -272,7 +273,6 @@ exist in `core::ops` and `core::cmp` with the same names.
[dereferences]: expressions/operator-expr.html#the-dereference-operator
[dereferencing]: expressions/operator-expr.html#the-dereference-operator
[dereference operator]: expressions/operator-expr.html#the-dereference-operator
[grouped]: expressions/operator-expr.html#grouped-expressions
[lazy boolean]: expressions/operator-expr.html#lazy-boolean-operators
[negation]: expressions/operator-expr.html#negation-operators
[overflow]: expressions/operator-expr.html#overflow
Expand Down
38 changes: 38 additions & 0 deletions src/expressions/grouped-expr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Grouped expressions

> **<sup>Syntax</sup>**
> _GroupedExpression_ :
> &nbsp;&nbsp; `(` [_Expression_] `)`

An expression enclosed in parentheses evaluates to the result of the enclosed
expression. Parentheses can be used to explicitly specify evaluation order
within an expression.

An example of a parenthesized expression:

```rust
let x: i32 = 2 + 3 * 4;
let y: i32 = (2 + 3) * 4;
assert_eq!(x, 14);
assert_eq!(y, 20);
```

An example of a necessary use of parentheses is when calling a function pointer
that is a member of a struct:

```rust
# struct A {
# f: fn() -> &'static str
# }
# impl A {
# fn f(&self) -> &'static str {
# "The method f"
# }
# }
# let a = A{f: || "The field f"};
#
assert_eq!( a.f (), "The method f");
assert_eq!((a.f)(), "The field f");
```

[_Expression_]: expressions.html
21 changes: 0 additions & 21 deletions src/expressions/operator-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,6 @@ overflow:
* Using `<<` or `>>` where the right-hand argument is greater than or equal to
the number of bits in the type of the left-hand argument, or is negative.

## Grouped expressions

> **<sup>Syntax</sup>**
> _GroupedExpression_ :
> &nbsp;&nbsp; `(` [_Expression_] `)`

An expression enclosed in parentheses evaluates to the result of the enclosed
expression. Parentheses can be used to explicitly specify evaluation order
within an expression.

This operator cannot be overloaded.

An example of a parenthesized expression:

```rust
let x: i32 = 2 + 3 * 4;
let y: i32 = (2 + 3) * 4;
assert_eq!(x, 14);
assert_eq!(y, 20);
```

## Borrow operators

> **<sup>Syntax</sup>**
Expand Down