From f7abbfc9fafa4c302c5cffe18e1c66e2f058bbf1 Mon Sep 17 00:00:00 2001 From: TruscaPetre <37754402+TruscaPetre@users.noreply.github.com> Date: Thu, 17 Nov 2022 23:57:44 +0200 Subject: [PATCH 1/2] A better phrasing for generic methods. --- src/ch10-01-syntax.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ch10-01-syntax.md b/src/ch10-01-syntax.md index c22aef7c36..f7b45ea400 100644 --- a/src/ch10-01-syntax.md +++ b/src/ch10-01-syntax.md @@ -216,8 +216,8 @@ generic type after `impl`, Rust can identify that the type in the angle brackets in `Point` is a generic type rather than a concrete type. We could have chosen a different name for this generic parameter than the generic parameter declared in the struct definition, but using the same name is -conventional. Methods written within an `impl` that declares the generic type -will be defined on any instance of the type, no matter what concrete type ends +conventional. If there is a method written within an `impl` that declares the generic type, +that method will be defined on any instance of the type, no matter what concrete type ends up substituting for the generic type. We can also specify constraints on generic types when defining methods on the From 17e2dcb38212554ee9d174679f0df8fee3b9ee8e Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Wed, 18 Dec 2024 15:41:42 -0700 Subject: [PATCH 2/2] Ch. 10.1: further clarify graf about methods in `impl ...` blocks --- src/ch10-01-syntax.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ch10-01-syntax.md b/src/ch10-01-syntax.md index 2ccbfad76b..fa8b5b1eb0 100644 --- a/src/ch10-01-syntax.md +++ b/src/ch10-01-syntax.md @@ -210,9 +210,9 @@ generic type after `impl`, Rust can identify that the type in the angle brackets in `Point` is a generic type rather than a concrete type. We could have chosen a different name for this generic parameter than the generic parameter declared in the struct definition, but using the same name is -conventional. If there is a method written within an `impl` that declares the generic type, -that method will be defined on any instance of the type, no matter what concrete type ends -up substituting for the generic type. +conventional. If you write a method within an `impl` that declares a generic +type, that method will be defined on any instance of the type, no matter what +concrete type ends up substituting for the generic type. We can also specify constraints on generic types when defining methods on the type. We could, for example, implement methods only on `Point` instances