Skip to content

Commit

Permalink
Go with 'memory location' over 'place'
Browse files Browse the repository at this point in the history
  • Loading branch information
Havvy committed Dec 8, 2017
1 parent 4ad306c commit bfc6eec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/expressions/array-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ greater than 1 then this requires that the type of `a` is
[Array and slice](types.html#array-and-slice-types)-typed expressions can be
indexed by writing a square-bracket-enclosed expression (the index) after them.
When the array is mutable, the resulting [place] can be assigned to.
When the array is mutable, the resulting [memory location] can be assigned to.
For other types an index expression `a[b]` is equivalent to
`*std::ops::Index::index(&a, b)`, or `*std::opsIndexMut::index_mut(&mut a, b)`
in a mutable place expression context. Just as with methods, Rust will also
Expand Down Expand Up @@ -69,7 +69,7 @@ The array index expression can be implemented for types other than arrays and sl
by implementing the [Index] and [IndexMut] traits.

[_Expression_]: expressions.html
[place]: expressions.html#place-expressions-and-value-expressions
[memory location]: expressions.html#place-expressions-and-value-expressions
[Index]: ../std/ops/trait.Index.html
[IndexMut]: ../std/ops/trait.IndexMut.html
[constant expression]: expressions.html#constant-expressions
3 changes: 2 additions & 1 deletion src/expressions/match-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ the pattern are assigned to local variables in the arm's block, and control
enters the block.

When the head expression is a [place expression], the match does not allocate a
temporary location; however, a by-value binding may copy or move from the place.
temporary location; however, a by-value binding may copy or move from the
memory location.
When possible, it is preferable to match on place expressions, as the lifetime
of these matches inherits the lifetime of the place expression rather than being
restricted to the inside of the match.
Expand Down
21 changes: 10 additions & 11 deletions src/expressions/operator-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@ assert_eq!(y, 20);

The `&` (shared borrow) and `&mut` (mutable borrow) operators are unary prefix
operators. When applied to a [place expression], this expressions produces a
reference (pointer) to the location that the value refers to. The place is also
placed into a borrowed state for the duration of the reference. For a shared
borrow (`&`), this implies that the place may not be mutated, but it may be read
or shared again. For a mutable borrow (`&mut`), the place may not be accessed in
any way until the borrow expires. `&mut` evaluates its operand in a mutable
place expression context. If the `&` or `&mut` operators are applied to a [value
expression], then a temporary value is created; the lifetime of this temporary
value is defined by [syntactic rules].
reference (pointer) to the location that the value refers to. The memory
location is also placed into a borrowed state for the duration of the reference.
For a shared borrow (`&`), this implies that the place may not be mutated, but
it may be read or shared again. For a mutable borrow (`&mut`), the place may not
be accessed in any way until the borrow expires. `&mut` evaluates its operand in
a mutable place expression context. If the `&` or `&mut` operators are applied
to a [value expression], then a [temporary value] is created.

These operators cannot be overloaded.

Expand All @@ -70,8 +69,8 @@ The `*` (dereference) operator is also a unary prefix operator. When applied to
a [pointer](types.html#pointer-types) it denotes the pointed-to location. If
the expression is of type `&mut T` and `*mut T`, and is either a local
variable, a (nested) field of a local variance or is a mutable [place
expression], then the resulting place can be assigned to. Dereferencing a raw
pointer requires `unsafe`.
expression], then the resulting memory location can be assigned to.
Dereferencing a raw pointer requires `unsafe`.

On non-pointer types `*x` is equivalent to `*std::ops::Deref::deref(&x)` in an
[immutable place expression context](expressions.html#mutability) and
Expand Down Expand Up @@ -336,7 +335,7 @@ assert_eq!(x, 14);

[place expression]: expressions.html#place-expressions-and-value-expressions
[value expression]: expressions.html#place-expressions-and-value-expressions
[syntactic rules]: expressions.html#temporary-lifetimes
[temporary value]: expressions.html#temporary-lifetimes
[float-int]: https://github.com/rust-lang/rust/issues/10184
[float-float]: https://github.com/rust-lang/rust/issues/15536
[`unit` type]: types.html#tuple-types

0 comments on commit bfc6eec

Please sign in to comment.