-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 more docs for CoerceUnsized and Unsize #38816
Conversation
ac0dc35
to
9688e8d
Compare
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.
Seems good on the technical aspects, otherwise.
/// `Unsize` is implemented for: | ||
/// | ||
/// - `[T; N]` is `Unsize<[T]>` | ||
/// - `T` is `Trait` when `T: Trait` |
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.
Should be T
is Unsize<Trait>
when T: Trait
, in order to be consistent with the above sentence.
/// See the [DST coercion RfC][dst-coerce] and [the nomicon entry on coercion][nomicon-coerce] | ||
/// for more details. | ||
/// | ||
/// For builtin types, pointers to `T` will coerce to pointers to `U` if `T: Unsize<U>` |
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.
"For builtin types" sounds unclear; perhaps reword this to say something to the effect of "for builtin pointer types".
/// field and coerce that. | ||
/// | ||
/// Generally, for smart pointers you will implement | ||
/// `CoerceUnsized<Ptr<U>> for Ptr<T> where T: Unsize<U>, U: ?Sized`, with an |
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; where U: ?Sized
is, afaik, not valid syntax. Another argument for supporting it?
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.
Yes. The docs also output this form. There is no reason not to support it IMO.
9688e8d
to
07e844f
Compare
Updated. |
Thanks! @bors: r+ rollup |
📌 Commit 07e844f has been approved by |
…meGomez Add more docs for CoerceUnsized and Unsize here be dragons r? @ubsan @steveklabnik
…meGomez Add more docs for CoerceUnsized and Unsize here be dragons r? @ubsan @steveklabnik
cc @rust-lang/lang to make sure the docs fit our beliefs |
…meGomez Add more docs for CoerceUnsized and Unsize here be dragons r? @ubsan @steveklabnik
here be dragons
r? @ubsan @steveklabnik