10}
11
12▶// we now declare a function which takes an object implementing the Foo trait
13fn some_func<T: Foo>(foo: T) {
14 foo.bar();
· · ·
13▶fn some_func<T: Foo>(foo: T) {
14 foo.bar();
15}
· · ·
16
17▶fn main() {
18 // we now call the method with the i32 type, which doesn't implement
19 // the Foo trait
· · ·
20▶ some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied
21}
22```
· · ·
35}
36
37▶fn some_func<T: Foo>(foo: T) {
38 foo.bar(); // we can now use this method since i32 implements the
39 // Foo trait
+ 12 more matches in this file