New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic information about associated types #23573
Conversation
|
(rust_highfive has picked a reviewer for you, use r? to override) |
|
Could you add a blurb about stuff like |
| % Associated Types | ||
|
|
||
| Associated types are a powerful part of Rust's type system. They're related to | ||
| the idea of a 'type family,' in other words, grouping multiple types together. That |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: comma after quote
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Associated types can definitely take quite a deep dive into how much we explain them (as @Manishearth pointed out), but I'm not sure how exhaustive this documentation wants to be. I feel like the book wants to stay fairly light so it doesn't really need to go into the gory details of |
|
|
||
| ```rust | ||
| trait Graph { | ||
| type N; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider comparing it to an alias: type Inches = i32 because aliasing may be familiar. It look me a while to realize these both used the same keyword and that an associated type wasn't just using some new syntax someone conjured strictly for this purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than looking like one, they're not really connected in any way though. I'd find this more confusing, I'd think.
Yeah, at least at the moment, I'd just like to get a solid base in. We currently have no documentation at all for associated types, so I'd like to land the core stuff, and then we can add more later. |
d9787a7
to
f2996c0
Compare
|
I added a section on trait objects which shows off that syntax. |
|
@bors: rollup |
|
|
No description provided.