Improve documentation of align_of and Alignment.#157500
Open
kpreid wants to merge 1 commit into
Open
Conversation
* The documentation for `align_of_val()` and `Alignment::of_val()` did not explain its use in interacting with `dyn` types, and even contained the false statement that “Every reference to a value of the type `T` must be a multiple of this number”. This change removes that statement from everything except `align_of()`, and adds a mention of, and example code for, getting the alignment of a `dyn` value. * The documentation for `align_of_val_raw()` did not explain how it relates to other functions in the family. Now it does. * Added a caveat that the alignment of `i32` is not always 4, despite the examples asserting this.
Collaborator
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The documentation for
align_of_val()andAlignment::of_val()did not explain its use in interacting withdyntypes, and even contained the false statement that “Every reference to a value of the typeTmust be a multiple of this number”. This change removes that statement from everything exceptalign_of(), and adds a mention of, and example code for, getting the alignment of adynvalue.The documentation for
align_of_val_raw()did not explain how it relates to other functions in the family. Now it does.Added a caveat that the alignment of
i32is not always 4, despite the examples asserting this.@rustbot label A-docs