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.
Currently
Bytes
(added in #277) supports some const size array types (e.g.[u8; N]
andBox<[u8; N]>
)but not others (e.g.
&[u8; N]
andCow<'_, [u8; N]>
).This pull request implements
Bytes
support for&[u8; N]
andCow<'_, [u8; N]>
This bring parity between dynamic and const sized types.
Before:
[u8; N]
&[u8; N]
Cow<'_, [u8; N]>
Box<[u8; N]>
Vec<u8>
*&[u8]
Cow<'_, [u8]>
Box<[u8]>
After:
[u8; N]
&[u8; N]
Cow<'_, [u8; N]>
Box<[u8; N]>
Vec<u8>
*&[u8]
Cow<'_, [u8]>
Box<[u8]>
I've also added a separate commit with an example of using fully borrowed types, but that example only does serialization
because RON doesn't support 0-copy deserialization for byte arrays (as it needs to decode them from base64).
Because of that I'm not sure if this example is useful so feel free to merge only the main commit.
* Technically
[u8]
corresponds to[u8; N]
but[u8]
is an unSized
type and cannot bedirectly used in structs.