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