2014-02-05 16:33:10 -06:00
|
|
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-10-15 01:05:01 -05:00
|
|
|
#![crate_name="trait_default_method_xc_aux"]
|
2013-06-12 16:22:17 -05:00
|
|
|
|
2014-03-28 13:09:31 -05:00
|
|
|
pub struct Something { pub x: int }
|
2013-07-02 16:39:25 -05:00
|
|
|
|
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 }
|
|
|
|
}
|
|
|
|
|
2014-01-17 17:23:19 -06:00
|
|
|
pub trait B<T> {
|
2013-06-12 16:22:17 -05:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|