-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Description
- I have checked the latest
mainbranch to see if this has already been fixed - I have searched existing issues and pull requests for duplicates
URL to the section(s) of the book with this problem:
https://doc.rust-lang.org/book/ch10-01-syntax.html
Description of the problem:
When defining a function that uses generics, we place the generics in the signature of the function where we would usually specify the data types of the parameters and return value. Doing so makes our code more flexible and provides more functionality to callers of our function while preventing code duplication.
Is this saying that placing the generic in the signature is what causes the code to be more flexible, or just using generics in general? As I'm still learning Rust I'm not sure, but I'm feeling like its the latter, but it's reading as if it's the former.
Suggested fix:
If it is indeed the latter that needs to apply, maybe it could read something like this:
When defining a function that uses generics, we place the generics in the signature of the function where we would usually specify the data types of the parameters and return value. Adding generics makes our code more flexible and provides more functionality to callers of our function while preventing code duplication.