Skip to content

Commit

Permalink
Remove binary move from the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
catamorphism committed Oct 23, 2012
1 parent 3bf0a9b commit 804c608
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 40 deletions.
40 changes: 1 addition & 39 deletions doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -1728,38 +1728,6 @@ fn avg(v: &[float]) -> float {
}
~~~~


#### Binary move expressions

A _binary move expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) followed by a left-pointing
arrow (`<-`) and an [rvalue](#lvalues-rvalues-and-temporaries) expression.

Evaluating a move expression causes, as a side effect,
the rvalue to be *moved* into the lvalue.
If the rvalue was itself an lvalue, it must be a local variable,
as it will be de-initialized in the process.

Evaluating a move expression does not change reference counts,
nor does it cause a deep copy of any owned structure pointed to by the moved rvalue.
Instead, the move expression represents an indivisible *transfer of ownership*
from the right-hand-side to the left-hand-side of the expression.
No allocation or destruction is entailed.

An example of three different move expressions:

~~~~~~~~
# let mut x = &[mut 0];
# let a = &[mut 0];
# let b = 0;
# let y = {mut z: 0};
# let c = 0;
# let i = 0;
x <- a;
x[i] <- b;
y.z <- c;
~~~~~~~~

#### Swap expressions

A _swap expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) followed by a bi-directional arrow (`<->`) and another [lvalue](#lvalues-rvalues-and-temporaries).
Expand Down Expand Up @@ -1792,21 +1760,15 @@ y.z <-> b.c;
An _assignment expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) expression followed by an
equals sign (`=`) and an [rvalue](#lvalues-rvalues-and-temporaries) expression.

Evaluating an assignment expression is equivalent to evaluating a [binary move
expression](#binary-move-expressions) applied to a [unary copy
expression](#unary-copy-expressions). For example, the following two
expressions have the same effect:
Evaluating an assignment expression copies the expression on the right-hand side and stores it in the location on the left-hand side.

~~~~
# let mut x = 0;
# let y = 0;
x = y;
x <- copy y;
~~~~

The former is just more terse and familiar.

#### Compound assignment expressions

The `+`, `-`, `*`, `/`, `%`, `&`, `|`, `^`, `<<`, and `>>`
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial-borrowed-ptr.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ fn example5c(x: @S) -> int {
let y = &v.g;
...
}
x.f <- v; // Replace x.f
x.f = move v; // Replace x.f
...
# return 0;
}
Expand Down

0 comments on commit 804c608

Please sign in to comment.