We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 98b18f5 + 9e25a1c commit ff2f745Copy full SHA for ff2f745
src/doc/trpl/ufcs.md
@@ -109,19 +109,28 @@ Here’s an example of using the longer form.
109
110
```rust
111
trait Foo {
112
- fn clone(&self);
+ fn foo() -> i32;
113
}
114
115
-#[derive(Clone)]
116
struct Bar;
117
118
-impl Foo for Bar {
119
- fn clone(&self) {
120
- println!("Making a clone of Bar");
+impl Bar {
+ fn foo() -> i32 {
+ 20
+ }
121
+}
122
- <Bar as Clone>::clone(self);
123
+impl Foo for Bar {
124
125
+ 10
126
127
128
+
129
+fn main() {
130
+ assert_eq!(10, <Bar as Foo>::foo());
131
+ assert_eq!(20, Bar::foo());
132
133
```
134
-This will call the `Clone` trait’s `clone()` method, rather than `Foo`’s.
135
+Using the angle bracket syntax lets you call the trait method instead of the
136
+inherent one.
0 commit comments