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:
@@ -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!
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user