2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2018-08-31 13:02:01 +00:00
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
#![allow(non_upper_case_globals)]
|
|
|
|
|
2013-05-25 02:35:29 +00:00
|
|
|
use std::cmp;
|
2012-08-08 00:11:43 +00:00
|
|
|
|
2015-01-28 13:34:18 +00:00
|
|
|
#[derive(Debug)]
|
2015-03-26 00:06:52 +00:00
|
|
|
struct foo { a: isize, b: isize, c: isize }
|
2012-08-08 00:11:43 +00:00
|
|
|
|
2014-05-30 00:45:07 +00:00
|
|
|
impl cmp::PartialEq for foo {
|
2013-03-22 18:23:21 +00:00
|
|
|
fn eq(&self, other: &foo) -> bool {
|
2012-11-15 02:59:30 +00:00
|
|
|
(*self).a == (*other).a &&
|
|
|
|
(*self).b == (*other).b &&
|
|
|
|
(*self).c == (*other).c
|
2012-08-27 23:26:35 +00:00
|
|
|
}
|
2013-03-22 18:23:21 +00:00
|
|
|
fn ne(&self, other: &foo) -> bool { !(*self).eq(other) }
|
2012-08-27 23:26:35 +00:00
|
|
|
}
|
|
|
|
|
2014-10-07 04:16:35 +00:00
|
|
|
const x : foo = foo { a:1, b:2, c: 3 };
|
|
|
|
const y : foo = foo { b:2, c:3, a: 1 };
|
|
|
|
const z : &'static foo = &foo { a: 10, b: 22, c: 12 };
|
|
|
|
const w : foo = foo { a:5, ..x };
|
2012-08-08 00:11:43 +00:00
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main() {
|
2013-05-19 02:02:45 +00:00
|
|
|
assert_eq!(x.b, 2);
|
|
|
|
assert_eq!(x, y);
|
|
|
|
assert_eq!(z.b, 22);
|
2013-07-27 03:49:42 +00:00
|
|
|
assert_eq!(w.a, 5);
|
|
|
|
assert_eq!(w.c, 3);
|
2013-09-25 05:16:43 +00:00
|
|
|
println!("{:#x}", x.b);
|
|
|
|
println!("{:#x}", z.c);
|
2012-08-08 00:11:43 +00:00
|
|
|
}
|