about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-11-17 15:12:14 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-11-17 15:12:14 +0530
commitff2f74561de9ef90f1ff1c932b98037e21c8cbbd (patch)
treeb0b0a131c565a8d6bfa5a49c97ffcd68892b739d
parent98b18f5e8ebac5ceea3a72cebc0b18a7cb7b8469 (diff)
parent9e25a1ccd32b3dd3e02ba841174fd620651bfb67 (diff)
downloadrust-ff2f74561de9ef90f1ff1c932b98037e21c8cbbd.tar.gz
rust-ff2f74561de9ef90f1ff1c932b98037e21c8cbbd.zip
Rollup merge of #29873 - steveklabnik:gh29493, r=nikomatsakis
Fixes #29493
-rw-r--r--src/doc/trpl/ufcs.md23
1 files changed, 16 insertions, 7 deletions
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");
+impl Bar {
+    fn foo() -> i32 {
+        20
+    }
+}
 
-        <Bar as Clone>::clone(self);
+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` trait’s `clone()` method, rather than `Foo`’s.
+Using the angle bracket syntax lets you call the trait method instead of the
+inherent one.