Skip to content
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

Document TryFromBytes #974

Merged
merged 1 commit into from
Feb 29, 2024
Merged

Document TryFromBytes #974

merged 1 commit into from
Feb 29, 2024

Conversation

jswrenn
Copy link
Collaborator

@jswrenn jswrenn commented Feb 29, 2024

Makes progress towards #5.

src/lib.rs Outdated
///
/// WARNING: Do not implement this trait yourself! Instead, use
/// `#[derive(TryFromBytes)]`.
/// This derive synthesizes the runtime checks required to check if a sequence
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// This derive synthesizes the runtime checks required to check if a sequence
/// This derive synthesizes the runtime checks required to check whether a sequence

Copy link
Collaborator Author

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
/// Types for which some bit patterns are valid.
///
/// A memory region of the appropriate length which contains initialized bytes
/// can be viewed as a `TryFromBytes` type so long as the runtime value of bytes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// can be viewed as a `TryFromBytes` type so long as the runtime value of bytes
/// can be viewed as a `TryFromBytes` type so long as the runtime value of those bytes

Copy link
Collaborator Author

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 Show resolved Hide resolved
src/lib.rs Outdated
/// A memory region of the appropriate length which contains initialized bytes
/// can be viewed as a `TryFromBytes` type so long as the runtime value of bytes
/// correspond to a [*valid instance*] of that type. For example, [`bool`] is
/// `TryFromBytes`; zerocopy can transmute a [`bool`] into a [`u8`] so long as
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// `TryFromBytes`; zerocopy can transmute a [`bool`] into a [`u8`] so long as
/// `TryFromBytes`; zerocopy can transmute a [`u8`] into a [`bool`] so long as

Also, this isn't technically true in our API (right now). We don't have try_transmute!, so we can't actually do this. Maybe say something like "zerocopy can transmute a [u8] into a bool..."?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Makes progress towards #5.
@joshlf joshlf added this pull request to the merge queue Feb 29, 2024
Merged via the queue into main with commit cac291e Feb 29, 2024
210 checks passed
@joshlf joshlf deleted the doc-tryfrombytes branch February 29, 2024 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants