Uh oh!
There was an error while loading. Please reload this page.
zeroize: support unsized types in Zeroizing - #1318
Conversation
6a5c7cc to
c20be21CompareThis commit adds ?Sized to the generic bounds on Zeroizing and many of its trait implementations. This makes it possible to form and use types like `Zeroizing<Box<[u8]>>` and `Zeroizing<Arc<[u8]>>`.
c20be21 to
e8007cbCompare| // This is a weird way to use zeroizing, but it's technically allowed b/c | ||
| // unsized types can be stored inside Zeroizing, so make sure it works as | ||
| // expected. | ||
| #[test] |
There was a problem hiding this comment.
I think this is missing a feature = "alloc" guard since it uses Box, but it seems like the build is still passing. Are these guards actually required?
There was a problem hiding this comment.
Since these tests are in tests/ they're in their own toplevel crate which links alloc and std by default.
You only need to gate alloc if it's using alloc-dependent functionality inside Zeroize. Since this is Box<Zeroizing<[u8]>> and not Zeroizing<Box<[u8]>> (which would need the Zeroize impl on Box) you're not actually dependent on zeroize having its alloc feature enabled.
tarcieri
commented
Jan 4, 2026
Going to go ahead and merge this. I might revisit the feature-gating myself. |
Uh oh!
There was an error while loading. Please reload this page.
## Added - `Zeroizing` is now `repr(transparent)` ([#1253]) - `optimization_barrier` function ([#1261]) - `Zeroizing` now supports `?Sized` ([#1318]) - `zeroize_stack` function ([#1331]) ## Changed - Edition changed to 2024 and MSRV bumped to 1.85 ([#1149]) - Replace `atomic_fence` with `optimization_barrier` ([#1252]) - Bump `zeroize_derive` to v1.5 ([#1492]) - Always enable AVX-512 support ([#1493]) [#1149]: #1149 [#1252]: #1252 [#1253]: #1253 [#1261]: #1261 [#1318]: #1318 [#1331]: #1331 [#1492]: #1492 [#1493]: #1493
This commit adds
?Sizedto the generic bounds on Zeroizing and many of its trait implementations. This makes it possible to form and use types likeZeroizing<Box<[u8]>>andZeroizing<Arc<[u8]>>.This also allows forming more exotic types like
Zeroizing<dyn SomeTrait>whereSomeTrait: Zeroize. I've included a test for that case to ensure that nothing unexpected breaks if it's used in that way, but that usage is probably not to be recommended.See #1256 for more details.