rust/tests/ui/traits/default-method/self.rs

19 lines
263 B
Rust
Raw Normal View History

//@ run-pass
trait Cat {
2013-05-08 04:15:08 +00:00
fn meow(&self) -> bool;
fn scratch(&self) -> bool { self.purr() }
fn purr(&self) -> bool { true }
}
impl Cat for isize {
2013-05-08 04:15:08 +00:00
fn meow(&self) -> bool {
self.scratch()
}
}
pub fn main() {
2013-03-29 01:39:09 +00:00
assert!(5.meow());
}