diff --git a/src/doc/trpl/ufcs.md b/src/doc/trpl/ufcs.md index 2353c63a606..7725970564b 100644 --- a/src/doc/trpl/ufcs.md +++ b/src/doc/trpl/ufcs.md @@ -109,19 +109,28 @@ Here’s 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"); - - ::clone(self); +impl Bar { + fn foo() -> i32 { + 20 } } + +impl Foo for Bar { + fn foo() -> i32 { + 10 + } +} + +fn main() { + assert_eq!(10, ::foo()); + assert_eq!(20, Bar::foo()); +} ``` -This will call the `Clone` trait’s `clone()` method, rather than `Foo`’s. +Using the angle bracket syntax lets you call the trait method instead of the +inherent one.