-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Clarify the English translation of ?Sized
#33747
Conversation
* It wasn't clear whether `?Sized` meant "not `Sized`" or "`Sized` or not `Sized`". According to #rust IRC, it does indeed mean "`Sized` or not `Sized`". * Use the same language as [Trait std::marker::Sized](https://doc.rust-lang.org/std/marker/trait.Sized.html) about how `Sized` is implicitly bound.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Manishearth (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
lets us match more kinds, not less. It’s almost like every `T` implicitly has | ||
`T: Sized`, and the `?` undoes this default. | ||
This `?Sized`, read as “T may or may not be `Sized`”, allowing us to match both constant size and unsized types. | ||
All generic type parameters implicitly have the `Sized` bound, so `?Sized` can be used to opt-out of the implicit bound. |
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.
Small nit, the line wrapping here is different to the rest of the file, it should probably be whatever the rest of the text is (looks like 80 chars?).
This `?`, read as “T may be `Sized`”, means that this bound is special: it | ||
lets us match more kinds, not less. It’s almost like every `T` implicitly has | ||
`T: Sized`, and the `?` undoes this default. | ||
This `?Sized`, read as “T may or may not be `Sized`”, allowing us to match both |
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: allowing -> allows
This `?Sized`, read as “T may or may not be `Sized`”, allowing us to match both | ||
constant size and unsized types. All generic type parameters implicitly have | ||
the `Sized` bound, so `?Sized` can be used to opt-out of the implicit bound. | ||
This `?Sized`, read as “T may or may not be `Sized`”, which allows us to match |
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.
Sorry, I think this is still not quite right...
My understanding is that you should be able to remove the appositive (the part between the commas) and still have a valid sentence. So I think the word "which" here is extraneous.
I'd prefer if someone else could chime in here as well on the grammar.
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'm horrible with grammar, so I'll defer.
Thanks for this @postmodern ! It is an area where, like the feature itself, the docs are a bit patched together.... |
* Use "special bound syntax" instead of "special syntax". `?Sized` is technically a "bound", but `?Sized` is specialized syntax that _only_ works with `Sized`, and no other Trait. * Replace "constant size" with "sized".
Edited yet again. I now refer to |
@bors r+ rollup |
📌 Commit 71af58a has been approved by |
Clarify the English translation of `?Sized` * It wasn't clear whether `?Sized` meant "not `Sized`" or "`Sized` or not `Sized`". According to #rust IRC, it does indeed mean "`Sized` or not `Sized`". * Use the same language as [Trait std::marker::Sized](https://doc.rust-lang.org/std/marker/trait.Sized.html) about how `Sized` is implicitly bound. * Refer to the syntax as `?Sized`, since it's currently the only allowed trait that can follow `?`.
lets us match more kinds, not less. It’s almost like every `T` implicitly has | ||
`T: Sized`, and the `?` undoes this default. | ||
This `?Sized`, read as “T may or may not be `Sized`”, which allows us to match | ||
both sized and unsized types. All generic type parameters implicitly |
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.
"which" should be removed from the first sentence.
?Sized
meant "notSized
" or "Sized
or notSized
". According to #rust IRC, it does indeed mean "Sized
or notSized
".Sized
is implicitly bound.?Sized
, since it's currently the only allowed trait that can follow?
.