We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ac468b6 commit 434c314Copy full SHA for 434c314
src/doc/reference.md
@@ -3755,6 +3755,21 @@ The special type `Self` has a meaning within traits and impls. In a trait defini
3755
to an implicit type parameter representing the "implementing" type. In an impl,
3756
it is an alias for the implementing type. For example, in:
3757
3758
+```
3759
+pub trait From<T> {
3760
+ fn from(T) -> Self;
3761
+}
3762
+
3763
+impl From<i32> for String {
3764
+ fn from(x: i32) -> Self {
3765
+ x.to_string()
3766
+ }
3767
3768
3769
3770
+The notation `Self` in the impl refers to the implementing type: `String`. In another
3771
+example:
3772
3773
```
3774
trait Printable {
3775
fn make_string(&self) -> String;
0 commit comments