swap function order for better read flow
When having the order ``` foo.bar(); // we can now use this method since i32 implements the Foo trait [...] impl Foo for i32 ``` the `// we can now use this method` comment is less clear to me.
This commit is contained in:
parent
703f2e1685
commit
a56d0e2f6e
1 changed files with 5 additions and 5 deletions
|
@ -29,16 +29,16 @@ trait Foo {
|
|||
fn bar(&self);
|
||||
}
|
||||
|
||||
fn some_func<T: Foo>(foo: T) {
|
||||
foo.bar(); // we can now use this method since i32 implements the
|
||||
// Foo trait
|
||||
}
|
||||
|
||||
// we implement the trait on the i32 type
|
||||
impl Foo for i32 {
|
||||
fn bar(&self) {}
|
||||
}
|
||||
|
||||
fn some_func<T: Foo>(foo: T) {
|
||||
foo.bar(); // we can now use this method since i32 implements the
|
||||
// Foo trait
|
||||
}
|
||||
|
||||
fn main() {
|
||||
some_func(5i32); // ok!
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue