-
Notifications
You must be signed in to change notification settings - Fork 111
[codec] Add Zeroed type #1804
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
base: main
Are you sure you want to change the base?
[codec] Add Zeroed type #1804
Conversation
80453d3
to
172471f
Compare
pub struct Zeroed { | ||
n: usize, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make more sense to have Zeroed<const N: usize>
similar to the FixedSize
type in utils/
? Then the read_cfg
Read::Cfgtype could be
()`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it looks like that in stable Rust currently, only constants that are independent of generic type resolution can be used in const generics.
Associated constants of traits (e.g. V::SIZE) are type-dependent and therefore cannot currently appear in const generic arguments. This is the tracking issue on rust to enable generic const expres

172471f
to
b61820e
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #1804 +/- ##
==========================================
+ Coverage 92.18% 92.29% +0.11%
==========================================
Files 302 305 +3
Lines 77980 79221 +1241
==========================================
+ Hits 71885 73118 +1233
- Misses 6095 6103 +8
... and 52 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
b61820e
to
60e1242
Compare
Introduced the
Zeroed
codec type: a useful type for encoding/decoding zero-padded data of a specific length without any memory allocation.When reading from buffer, it avoids heap-allocating a vector by "peeking" the input buffer via
.chunk()[..len]
: the buffer is advanced only if the given chunk has all zerosCloses #1703