2018-08-30 14:18:55 +02:00
|
|
|
//@ run-pass
|
2015-03-22 13:13:15 -07:00
|
|
|
|
2012-11-12 12:15:08 -08:00
|
|
|
mod a {
|
2013-05-03 19:25:04 -04:00
|
|
|
pub trait Foo {
|
2013-08-09 01:25:24 -07:00
|
|
|
fn foo() -> Self;
|
2013-05-03 19:25:04 -04:00
|
|
|
}
|
2012-11-12 12:15:08 -08:00
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
impl Foo for isize {
|
|
|
|
fn foo() -> isize {
|
2013-05-03 19:25:04 -04:00
|
|
|
3
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
impl Foo for usize {
|
|
|
|
fn foo() -> usize {
|
2015-03-03 10:42:26 +02:00
|
|
|
5
|
2013-05-03 19:25:04 -04:00
|
|
|
}
|
|
|
|
}
|
2012-11-12 12:15:08 -08:00
|
|
|
}
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2015-03-25 17:06:52 -07:00
|
|
|
let x: isize = a::Foo::foo();
|
|
|
|
let y: usize = a::Foo::foo();
|
2013-05-18 22:02:45 -04:00
|
|
|
assert_eq!(x, 3);
|
|
|
|
assert_eq!(y, 5);
|
2012-11-12 12:15:08 -08:00
|
|
|
}
|