2013-12-17 15:40:33 -06:00
|
|
|
#[crate_id="trait_default_method_xc_aux"];
|
2013-06-12 16:22:17 -05:00
|
|
|
|
2013-07-02 16:39:25 -05:00
|
|
|
pub struct Something { x: int }
|
|
|
|
|
2013-06-12 16:22:17 -05:00
|
|
|
pub trait A {
|
|
|
|
fn f(&self) -> int;
|
|
|
|
fn g(&self) -> int { 10 }
|
2013-07-11 17:08:43 -05:00
|
|
|
fn h(&self) -> int { 11 }
|
|
|
|
fn lurr(x: &Self, y: &Self) -> int { x.g() + y.h() }
|
2013-06-12 16:22:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl A for int {
|
|
|
|
fn f(&self) -> int { 10 }
|
|
|
|
}
|
|
|
|
|
2013-07-02 16:39:25 -05:00
|
|
|
impl A for Something {
|
|
|
|
fn f(&self) -> int { 10 }
|
|
|
|
}
|
|
|
|
|
2013-06-12 16:22:17 -05:00
|
|
|
trait B<T> {
|
|
|
|
fn thing<U>(&self, x: T, y: U) -> (T, U) { (x, y) }
|
2013-08-17 10:37:42 -05:00
|
|
|
fn staticthing<U>(_z: &Self, x: T, y: U) -> (T, U) { (x, y) }
|
2013-06-12 16:22:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<T> B<T> for int { }
|
2013-09-26 01:26:09 -05:00
|
|
|
impl B<f64> for bool { }
|
2013-06-12 16:22:17 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub trait TestEquality {
|
|
|
|
fn test_eq(&self, rhs: &Self) -> bool;
|
|
|
|
fn test_neq(&self, rhs: &Self) -> bool {
|
|
|
|
!self.test_eq(rhs)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl TestEquality for int {
|
|
|
|
fn test_eq(&self, rhs: &int) -> bool {
|
|
|
|
*self == *rhs
|
|
|
|
}
|
|
|
|
}
|