mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
29 lines
389 B
Rust
29 lines
389 B
Rust
// run-pass
|
|
|
|
|
|
// Tests that we can call a function bounded over a supertrait from
|
|
// a default method
|
|
|
|
fn require_y<T: Y>(x: T) -> isize { x.y() }
|
|
|
|
trait Y {
|
|
fn y(self) -> isize;
|
|
}
|
|
|
|
|
|
trait Z: Y + Sized {
|
|
fn x(self) -> isize {
|
|
require_y(self)
|
|
}
|
|
}
|
|
|
|
impl Y for isize {
|
|
fn y(self) -> isize { self }
|
|
}
|
|
|
|
impl Z for isize {}
|
|
|
|
pub fn main() {
|
|
assert_eq!(12.x(), 12);
|
|
}
|