| 241 | #[cfg(feature = "alloc")] |
| 242 | #[test] |
| 243 | fn 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 |