-
Notifications
You must be signed in to change notification settings - Fork 104
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
Rephrase conversion methods' documentation to accommodate DSTs #1269
Conversation
src/lib.rs
Outdated
/// length, alignment, or overflow checks fail, it returns `Err`. | ||
/// This method attempts to return a reference to the prefix of `bytes` | ||
/// reinterpreted as a `Self` with `count` trailing elements, and reference | ||
/// to the preceeding bytes. If there are insufficient bytes, or if `bytes` |
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.
/// to the preceeding bytes. If there are insufficient bytes, or if `bytes` | |
/// to the remaining bytes. If there are insufficient bytes, or if `bytes` |
Or something else, but "preceding" only works if this were a suffix cast.
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.
Done
src/lib.rs
Outdated
/// length, alignment, or overflow checks fail, it returns `Err`. | ||
/// This method attempts to return a reference to the suffix of `bytes` | ||
/// reinterpreted as a `Self` with `count` trailing elements, and reference | ||
/// to the preceeding bytes. If there are insufficient bytes, or if 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.
/// to the preceeding bytes. If there are insufficient bytes, or if that | |
/// to the preceding bytes. If there are insufficient bytes, or if 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.
Done
src/lib.rs
Outdated
/// If the bytes of `candidate` are a valid instance of `Self`, reads those | ||
/// bytes as `Self`. If `candidate.len() < size_of::<Self>()` or the bytes | ||
/// are not a valid instance of `Self`, this returns `Err`. | ||
/// If `candidate.len() < size_of::<Self>()` or the bytes are not a valid |
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.
/// If `candidate.len() < size_of::<Self>()` or the bytes are not a valid | |
/// If `candidate.len() != size_of::<Self>()` or the bytes are not a valid |
src/lib.rs
Outdated
/// This method attempts to return a reference to `bytes` interpreted as a | ||
/// `Self`. If there are insufficient or excess bytes, or if `bytes` is not | ||
/// aligned to `Self`'s alignment requirement, this returns `Err`. |
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.
Here I think the old wording - "valid length for Self
" (although I'd say size instead of length) - makes more sense. "Insufficient or excess" implies that there's one correct size, but that's not true - there could be many correct sizes.
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.
How could there be many correct sizes? Isn't this backed by a try_cast_into_no_leftover
?
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.
Ah, I see your point. There's only one correct size per DST length though.
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.
Yeah exactly
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.
src/lib.rs
Outdated
/// This method attempts to return a reference to `bytes` interpreted as a | ||
/// `Self`. If there are insufficient or excess bytes, or if `bytes` is not | ||
/// aligned to `Self`'s alignment requirement, this returns `Err`. |
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.
Same here as above.
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.
src/lib.rs
Outdated
/// bytes. If `bytes.len() < size_of::<Self>()` or `bytes` is not aligned to | ||
/// `align_of::<Self>()`, this returns `Err`. | ||
/// This method computes the largest possible size of `Self` that can fit in | ||
/// the leading bytes of `candidate`, then attempts to return both a |
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.
Whoops, this shouldn't be "bytes of candidate
".
"bytes of bytes
" is awkward, so perhaps I'll rename bytes
to source
.
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.
Done.
src/lib.rs
Outdated
/// `Self` with `count` trailing elements. If the length of `source` is not | ||
/// a valid size of `Self`, or if `source` is not appropriately aligned, |
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.
"Valid size of Self
" isn't the right condition when an explicit count is given.
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.
src/ref.rs
Outdated
/// the remaining bytes. If the length of `source` is not a valid size of | ||
/// `T`, or if `source` is not appropriately aligned, this returns `Err`. |
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.
"Valid size of T
" isn't the right condition when an explicit count is given.
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.
src/ref.rs
Outdated
/// the remaining bytes. If the length of `source` is not a valid size of | ||
/// `T`, this returns `Err`. |
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.
"Valid size of T
" isn't the right condition when an explicit count is given.
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.
src/ref.rs
Outdated
/// This method attempts to return a `Ref` to the suffix of `source` | ||
/// interpreted as a `T` with `count` trailing elements, and a reference to | ||
/// the preceding bytes. If there are insufficient bytes, or if that suffix | ||
/// of `source` is not appropriately aligned, this returns `Err`. |
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.
Alignment isn't required here.
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.
src/ref.rs
Outdated
/// This method attempts to return a `Ref` to the prefix of `source` | ||
/// interpreted as a `T` with `count` trailing elements, and a reference to | ||
/// the remaining bytes. If there are insufficient bytes, or if `source` is | ||
/// not appropriately aligned, this returns `Err`. |
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.
Alignment isn't required here.
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.
This entails removing reference to both
size_of
andalign_of
, which cannot be invoked on slice DSTs.