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

Function arc_unsized_zeroizing

zeroize/tests/zeroize.rs:255–272  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

253#[cfg(feature = "alloc")]
254#[test]
255fn arc_unsized_zeroizing() {
256 let mut arc: Arc<Zeroizing<[u8]>> = Arc::new(Zeroizing::new([1, 2, 3, 4]));
257 {
258 let s: &[u8] = &arc;
259 assert_eq!(s, &[1, 2, 3, 4]);
260
261 let s: &[u8] = arc.as_ref();
262 assert_eq!(s, &[1, 2, 3, 4]);
263 }
264
265 unsafe {
266 let inner = Arc::get_mut(&mut arc).unwrap();
267 ptr::drop_in_place(inner);
268 }
269
270 let s: &[u8] = &arc;
271 assert_eq!(s, &[0, 0, 0, 0]);
272}
273
274// This is a weird way to use zeroizing, but it's technically allowed b/c
275// 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