Implement traits for tuples #274
Labels
compatibility-nonbreaking
Changes that are (likely to be) non-breaking
experience-medium
This issue is of medium difficulty, and requires some experience
help wanted
Extra attention is needed
Although we do not do so currently, it's valid to implement
FromZeroes
andFromBytes
for tuples of any size, so long as all of the elements of those tuples also implement those traits. Use this as a model for how to provide generic implementations of these traits:zerocopy/src/lib.rs
Lines 1094 to 1108 in 0ff2dd1
Note: We cannot implement
Unaligned
norAsBytes
for any tuple type other than()
— all other tuple types have the default representation, and so a) there is no upper bound on their alignment and, b) there are no guarantees made about the absence of padding.Additionally, add tests for the presence/absence of these impls for various concrete tuple types (where the tuple element types are both sufficient and insufficient for generating the impl for the entire tuple). The
assert_impls!
macro may be helpful for this:zerocopy/src/lib.rs
Line 4512 in b083f1f
Following the lead of the standard library, we should implement these traits for tuples up to size 12.
The text was updated successfully, but these errors were encountered: