2015-11-20 04:11:08 -06:00
|
|
|
trait Foo<A> {
|
|
|
|
fn foo(&self, a: A) -> A {
|
|
|
|
a
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trait NotRelevant<A> {
|
|
|
|
fn nr(&self, a: A) -> A {
|
|
|
|
a
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Bar;
|
|
|
|
|
2015-11-28 04:42:25 -06:00
|
|
|
impl Foo<i8> for Bar {}
|
|
|
|
impl Foo<i16> for Bar {}
|
2015-11-20 04:11:08 -06:00
|
|
|
impl Foo<i32> for Bar {}
|
|
|
|
|
|
|
|
impl Foo<u8> for Bar {}
|
2015-11-28 04:42:25 -06:00
|
|
|
impl Foo<u16> for Bar {}
|
|
|
|
impl Foo<u32> for Bar {}
|
2015-11-20 04:11:08 -06:00
|
|
|
|
|
|
|
impl NotRelevant<usize> for Bar {}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let f1 = Bar;
|
|
|
|
|
|
|
|
f1.foo(1usize);
|
2016-04-05 14:56:23 -05:00
|
|
|
//~^ error: the trait bound `Bar: Foo<usize>` is not satisfied
|
2015-11-20 04:11:08 -06:00
|
|
|
}
|