2018-08-30 14:18:55 +02:00
|
|
|
//@ run-pass
|
2012-12-10 17:32:48 -08:00
|
|
|
|
2012-12-17 14:57:37 -08:00
|
|
|
|
2012-08-13 11:11:09 -07:00
|
|
|
trait Cat {
|
2013-03-12 19:32:14 -07:00
|
|
|
fn meow(&self) -> bool;
|
|
|
|
fn scratch(&self) -> bool;
|
|
|
|
fn purr(&self) -> bool { true }
|
2012-08-13 11:11:09 -07:00
|
|
|
}
|
|
|
|
|
2015-03-25 17:06:52 -07:00
|
|
|
impl Cat for isize {
|
2013-03-12 19:32:14 -07:00
|
|
|
fn meow(&self) -> bool {
|
2012-08-13 11:11:09 -07:00
|
|
|
self.scratch()
|
|
|
|
}
|
2013-03-12 19:32:14 -07:00
|
|
|
fn scratch(&self) -> bool {
|
2012-08-13 11:11:09 -07:00
|
|
|
self.purr()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2013-03-28 18:39:09 -07:00
|
|
|
assert!(5.meow());
|
2012-08-13 11:11:09 -07:00
|
|
|
}
|