()
| 472 | |
| 473 | #[test] |
| 474 | fn zeroize_with_drop() { |
| 475 | test_derive( |
| 476 | derive_zeroize_impl, |
| 477 | quote! { |
| 478 | #[zeroize(drop)] |
| 479 | struct Z { |
| 480 | a: String, |
| 481 | b: Vec<u8>, |
| 482 | c: [u8; 3], |
| 483 | } |
| 484 | }, |
| 485 | quote! { |
| 486 | impl ::zeroize::Zeroize for Z { |
| 487 | fn zeroize(&mut self) { |
| 488 | match self { |
| 489 | #[allow(unused_variables, unused_assignments)] |
| 490 | Z { a, b, c } => { |
| 491 | a.zeroize(); |
| 492 | b.zeroize(); |
| 493 | c.zeroize() |
| 494 | } |
| 495 | _ => {} |
| 496 | } |
| 497 | } |
| 498 | } |
| 499 | #[doc(hidden)] |
| 500 | impl Drop for Z { |
| 501 | fn drop(&mut self) { |
| 502 | self.zeroize() |
| 503 | } |
| 504 | } |
| 505 | }, |
| 506 | ); |
| 507 | } |
| 508 | |
| 509 | #[test] |
| 510 | fn zeroize_with_skip() { |
nothing calls this directly
no test coverage detected