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

Function arc_unsized_zeroizing

zeroize/tests/zeroize.rs:243–260  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

241#[cfg(feature = "alloc")]
242#[test]
243fn arc_unsized_zeroizing() {
244 let mut arc: Arc<Zeroizing<[u8]>> = Arc::new(Zeroizing::new([1, 2, 3, 4]));
245 {
246 let s: &[u8] = &arc;
247 assert_eq!(s, &[1, 2, 3, 4]);
248
249 let s: &[u8] = arc.as_ref();
250 assert_eq!(s, &[1, 2, 3, 4]);
251 }
252
253 unsafe {
254 let inner = Arc::get_mut(&mut arc).unwrap();
255 ptr::drop_in_place(inner);
256 }
257
258 let s: &[u8] = &arc;
259 assert_eq!(s, &[0, 0, 0, 0]);
260}
261
262// This is a weird way to use zeroizing, but it's technically allowed b/c
263// unsized types can be stored inside Zeroizing, so make sure it works as

Callers

nothing calls this directly

Calls 2

as_refMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected