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

Function box_unsized_zeroizing

zeroize/tests/zeroize.rs:232–251  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

230#[cfg(feature = "alloc")]
231#[test]
232fn box_unsized_zeroizing() {
233 let mut b: Box<Zeroizing<[u8]>> = Box::new(Zeroizing::new([1, 2, 3, 4]));
234 {
235 let s: &[u8] = &b;
236 assert_eq!(s, &[1, 2, 3, 4]);
237
238 let s: &[u8] = b.as_ref();
239 assert_eq!(s, &[1, 2, 3, 4]);
240
241 let s: &mut [u8] = b.as_mut();
242 assert_eq!(s, &[1, 2, 3, 4]);
243 }
244
245 unsafe {
246 ptr::drop_in_place(&raw mut *b);
247 }
248
249 let s: &[u8] = &b;
250 assert_eq!(s, &[0, 0, 0, 0]);
251}
252
253#[cfg(feature = "alloc")]
254#[test]

Callers

nothing calls this directly

Calls 2

as_refMethod · 0.45
as_mutMethod · 0.45

Tested by

no test coverage detected