[doc] TryFromBytes, IntoBytes aren't symmetrical#860
Merged
Conversation
Makes progress on #5
26 tasks
jswrenn
requested changes
Feb 12, 2024
Comment on lines
+1184
to
+1193
| /// # `TryFromBytes` is not symmetrical with [`IntoBytes`] | ||
| /// | ||
| /// There are some types which implement both `TryFromBytes` and [`IntoBytes`], | ||
| /// but for which `TryFromBytes` is not guaranteed to accept all byte sequences | ||
| /// produced by `IntoBytes`. In other words, for some `T: TryFromBytes + | ||
| /// IntoBytes`, there exist values of `t: T` such that | ||
| /// `TryFromBytes::try_from_ref(t.as_bytes()) == None`. Code should not | ||
| /// generally assume that values produced by `IntoBytes` will necessarily be | ||
| /// accepted as valid by `TryFromBytes`. | ||
| /// |
Collaborator
There was a problem hiding this comment.
Perhaps we could include an example here?
Member
Author
There was a problem hiding this comment.
We're in a catch-22 here. We intend to eventually add IntoBytes impls for reference and pointer types, but we don't have them yet (#170). Once we have them, they will be described by this section. However, we can't wait to add this section because, if we do, people might write generic code that relies on the thing we're telling them not to rely on here, and that code would only break in the future once we add those impls.
jswrenn
approved these changes
Feb 12, 2024
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.
I don't love how this is currently worded. I'd love suggestions on improving it.