-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Milestone
Description
As far as I know Self was first used in Chapter 10.2, Listing 10-17. It is easy to infer that it refers to Pair, but still it's better to mention it. Furthermore, it seems to be required and cannot be substituted for Pair or Pair<T>. I think it should be noted as well, because you can substitute concrete type for Self in associated functions for non-generic types, like was done in Chapter 5.3, section on Associated Functions. There we have
impl Rectangle {
fn square(size: u32) -> Rectangle {
Rectangle { width: size, height: size }
}
}which seems to be identical to
impl Rectangle {
fn square(size: u32) -> Self {
Self { width: size, height: size }
}
}Also, it would be good to explain the difference between Self and self.
By the way, I haven't read further than Chapter 10.2, so everything might be explained in later chapters, I don't know.
jrheard
Metadata
Metadata
Assignees
Labels
No labels