Rollup merge of #29873 - steveklabnik:gh29493, r=nikomatsakis

Fixes #29493
This commit is contained in:
Manish Goregaokar 2015-11-17 15:12:14 +05:30
commit ff2f74561d

View File

@ -109,19 +109,28 @@ Heres an example of using the longer form.
```rust
trait Foo {
fn clone(&self);
fn foo() -> i32;
}
#[derive(Clone)]
struct Bar;
impl Foo for Bar {
fn clone(&self) {
println!("Making a clone of Bar");
<Bar as Clone>::clone(self);
impl Bar {
fn foo() -> i32 {
20
}
}
impl Foo for Bar {
fn foo() -> i32 {
10
}
}
fn main() {
assert_eq!(10, <Bar as Foo>::foo());
assert_eq!(20, Bar::foo());
}
```
This will call the `Clone` traits `clone()` method, rather than `Foo`s.
Using the angle bracket syntax lets you call the trait method instead of the
inherent one.