auto merge of #18467 : japaric/rust/eq, r=alexcrichton
`eq`, `ne`, `cmp`, etc methods now require one less level of indirection when dealing with `&str`/`&[T]`
``` rust
"foo".ne(&"bar") -> "foo".ne("bar")
slice.cmp(&another_slice) -> slice.cmp(another_slice)
// slice and another_slice have type `&[T]`
```
[breaking-change]
This commit is contained in:
commit
e84e7a00dd
22 changed files with 635 additions and 29 deletions
|
|
@ -12,8 +12,8 @@ struct NoCloneOrEq;
|
|||
|
||||
#[deriving(PartialEq)]
|
||||
struct E {
|
||||
x: NoCloneOrEq //~ ERROR does not implement any method in scope named `eq`
|
||||
//~^ ERROR does not implement any method in scope named `ne`
|
||||
x: NoCloneOrEq //~ ERROR binary operation `==` cannot be applied to type `NoCloneOrEq`
|
||||
//~^ ERROR binary operation `!=` cannot be applied to type `NoCloneOrEq`
|
||||
}
|
||||
#[deriving(Clone)]
|
||||
struct C {
|
||||
|
|
|
|||
24
src/test/run-pass/deriving-eq-ord-boxed-slice.rs
Normal file
24
src/test/run-pass/deriving-eq-ord-boxed-slice.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[deriving(PartialEq, PartialOrd, Eq, Ord)]
|
||||
struct Foo(Box<[u8]>);
|
||||
|
||||
pub fn main() {
|
||||
let a = Foo(box [0, 1, 2]);
|
||||
let b = Foo(box [0, 1, 2]);
|
||||
assert!(a == b);
|
||||
println!("{}", a != b);
|
||||
println!("{}", a < b);
|
||||
println!("{}", a <= b);
|
||||
println!("{}", a == b);
|
||||
println!("{}", a > b);
|
||||
println!("{}", a >= b);
|
||||
}
|
||||
18
src/test/run-pass/issue-15689-1.rs
Normal file
18
src/test/run-pass/issue-15689-1.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[deriving(PartialEq)]
|
||||
enum Test<'a> {
|
||||
Slice(&'a int)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
assert!(Slice(&1) == Slice(&1))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue