]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
11 | // Test that a where clause attached to a method allows us to add | |
12 | // additional constraints to a parameter out of scope. | |
13 | ||
14 | struct Foo<T> { | |
15 | value: T | |
16 | } | |
17 | ||
18 | struct Bar; // does not implement Eq | |
19 | ||
20 | impl<T> Foo<T> { | |
21 | fn equals(&self, u: &Foo<T>) -> bool where T : Eq { | |
22 | self.value == u.value | |
23 | } | |
24 | } | |
25 | ||
26 | fn main() { | |
27 | let x = Foo { value: Bar }; | |
28 | x.equals(&x); | |
54a0048b | 29 | //~^ ERROR `Bar: std::cmp::Eq` is not satisfied |
1a4d82fc | 30 | } |