-
Notifications
You must be signed in to change notification settings - Fork 32
/
where-clauses-method-unsatisfied.rs
53 lines (48 loc) · 1.13 KB
/
where-clauses-method-unsatisfied.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Test that a where clause attached to a method allows us to add
// additional constraints to a parameter out of scope.
struct Foo<T> {
value: T
}
struct Bar; // does not implement Eq
impl<T> Foo<T> {
fn equals(&self, u: &Foo<T>) -> bool where T : Eq {
self.value == u.value
}
}
fn main() {
let x = Foo { value: Bar };
x.equals(&x);
//~^ ERROR `Bar: Eq` is not satisfied
}
// ferrocene-annotations: fls_9ucqbbd0s2yo
// Struct Types
//
// ferrocene-annotations: fls_fk2m2irwpeof
// Implementations
//
// ferrocene-annotations: fls_e1pgdlv81vul
// Implementation Conformance
//
// ferrocene-annotations: fls_142vncdktbin
// Reference Types
//
// ferrocene-annotations: fls_jeoas4n6su4
// Trait and Lifetime Bounds
//
// ferrocene-annotations: fls_z7q8kbjwdc7g
// Method Call Expressions
//
// ferrocene-annotations: fls_8tsynkj2cufj
// Struct Expressions
//
// ferrocene-annotations: fls_qztk0bkju9u
// Borrow Expression
//
// ferrocene-annotations: fls_a14slch83hzn
// Borrowing
//
// ferrocene-annotations: fls_izdv9i4spokw
// Operator Expressions
//
// ferrocene-annotations: fls_wqazkzle0ix9
// Method Resolution