Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rust][zerocopy] Implement fewer array types
Stable Rust does not yet support const generics, so zerocopy defines an impl_for_array_sizes! macro to implement a specified trait for a selection of [T; n] array lengths. This macro presently covers array lengths 0..=1024 plus powers of 2 up to 65536 totaling 1031 array lengths. It is used for 3 different traits, for a grand total of 3,093 array trait implementations. The Rust primitive array type implements the standard traits for array lengths 0..=32. The broader ecosystem tends to follow, especially including serde. zerocopy is in a slightly different position, but still there is a tradeoff weighing completeness against compile time, rlib size, and macro recursion depth. This change adjusts that tradeoff, now covering array lengths of 0..=64 plus powers of 2 up to 65536 plus a few Fuchsia-specific sizes totaling 79 array lengths and a grand total of 237 array trait implementations. This is 92% fewer than the baseline, which yields a 96% decrease in zerocopy's build time (e.g. `cargo check` went from 22.7s to 0.8s). This significant reduction in apparent complexity also indirectly benefits the development experience for any crate which uses zerocopy, any web browser which navigates documentation containing zerocopy, any IDE which attempts to autocomplete within a module using zerocopy, and so on. Change-Id: If978f7874a45efadde38e124c831c7dfe05caeb0
- Loading branch information