You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A _swap expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) followed by a bi-directional arrow (`<->`) and another [lvalue](#lvalues-rvalues-and-temporaries).
1952
-
1953
-
Evaluating a swap expression causes, as a side effect, the values held in the left-hand-side and right-hand-side [lvalues](#lvalues-rvalues-and-temporaries) to be exchanged indivisibly.
1954
-
1955
-
Evaluating a swap expression neither changes reference counts,
1956
-
nor deeply copies any owned structure pointed to by the moved [rvalue](#lvalues-rvalues-and-temporaries).
1957
-
Instead, the swap expression represents an indivisible *exchange of ownership*,
1958
-
between the right-hand-side and the left-hand-side of the expression.
1959
-
No allocation or destruction is entailed.
1960
-
1961
-
An example of three different swap expressions:
1962
-
1963
-
~~~~~~~~
1964
-
# let mut x = &mut [0];
1965
-
# let mut a = &mut [0];
1966
-
# let i = 0;
1967
-
# struct S1 { z: int };
1968
-
# struct S2 { c: int };
1969
-
# let mut y = S1{z: 0};
1970
-
# let mut b = S2{c: 0};
1971
-
1972
-
x <-> a;
1973
-
x[i] <-> a[i];
1974
-
y.z <-> b.c;
1975
-
~~~~~~~~
1976
-
1977
-
1978
1949
#### Assignment expressions
1979
1950
1980
1951
An _assignment expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) expression followed by an
@@ -2015,7 +1986,7 @@ as
2015
1986
== !=
2016
1987
&&
2017
1988
||
2018
-
= <->
1989
+
=
2019
1990
~~~~
2020
1991
2021
1992
Operators at the same precedence level are evaluated left-to-right.
0 commit comments