mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
17 lines
337 B
Rust
17 lines
337 B
Rust
// run-pass
|
|
use std::cmp::Ordering::{Less,Equal,Greater};
|
|
|
|
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
|
struct A<'a> {
|
|
x: &'a isize
|
|
}
|
|
pub fn main() {
|
|
let (a, b) = (A { x: &1 }, A { x: &2 });
|
|
|
|
assert_eq!(a.cmp(&a), Equal);
|
|
assert_eq!(b.cmp(&b), Equal);
|
|
|
|
assert_eq!(a.cmp(&b), Less);
|
|
assert_eq!(b.cmp(&a), Greater);
|
|
}
|