auto merge of #19899 : japaric/rust/unops-by-value, r=nikomatsakis
- The following operator traits now take their argument by value: `Neg`, `Not`. This breaks all existing implementations of these traits. - The unary operation `OP a` now "desugars" to `OpTrait::op_method(a)` and consumes its argument. [breaking-change] --- r? @nikomatsakis This PR is very similar to the binops-by-value PR cc @aturon
This commit is contained in:
commit
6bdce25e15
10 changed files with 195 additions and 14 deletions
|
|
@ -31,13 +31,13 @@ impl ops::Sub<Point,Point> for Point {
|
|||
}
|
||||
|
||||
impl ops::Neg<Point> for Point {
|
||||
fn neg(&self) -> Point {
|
||||
fn neg(self) -> Point {
|
||||
Point {x: -self.x, y: -self.y}
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::Not<Point> for Point {
|
||||
fn not(&self) -> Point {
|
||||
fn not(self) -> Point {
|
||||
Point {x: !self.x, y: !self.y }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue