MCPcopy Create free account
hub / github.com/RustCrypto/utils / box_unsized_zeroizing

Function box_unsized_zeroizing

zeroize/tests/zeroize.rs:220–239  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

218#[cfg(feature = "alloc")]
219#[test]
220fn box_unsized_zeroizing() {
221 let mut b: Box<Zeroizing<[u8]>> = Box::new(Zeroizing::new([1, 2, 3, 4]));
222 {
223 let s: &[u8] = &b;
224 assert_eq!(s, &[1, 2, 3, 4]);
225
226 let s: &[u8] = b.as_ref();
227 assert_eq!(s, &[1, 2, 3, 4]);
228
229 let s: &mut [u8] = b.as_mut();
230 assert_eq!(s, &[1, 2, 3, 4]);
231 }
232
233 unsafe {
234 ptr::drop_in_place(&raw mut *b);
235 }
236
237 let s: &[u8] = &b;
238 assert_eq!(s, &[0, 0, 0, 0]);
239}
240
241#[cfg(feature = "alloc")]
242#[test]

Callers

nothing calls this directly

Calls 2

as_refMethod · 0.45
as_mutMethod · 0.45

Tested by

no test coverage detected