rust/tests/ui/generics/issue-2936.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
408 B
Rust
Raw Normal View History

// run-pass
#![allow(non_camel_case_types)]
trait bar<T> {
fn get_bar(&self) -> T;
}
fn foo<T, U: bar<T>>(b: U) -> T {
b.get_bar()
}
struct cbar {
x: isize,
}
impl bar<isize> for cbar {
fn get_bar(&self) -> isize {
self.x
}
}
fn cbar(x: isize) -> cbar {
2012-09-05 22:58:43 +00:00
cbar {
x: x
}
}
pub fn main() {
let x: isize = foo::<isize, cbar>(cbar(5));
assert_eq!(x, 5);
}