diff --git a/zeroize/src/lib.rs b/zeroize/src/lib.rs index 3acdf803..7d19c1f9 100644 --- a/zeroize/src/lib.rs +++ b/zeroize/src/lib.rs @@ -295,7 +295,19 @@ where } } -/// Implement `Zeroize` on slices of types that can be zeroized with `Default`. +impl Zeroize for Option +where + Z: Zeroize +{ + fn zeroize(&mut self) { + match self { + Some(value) => value.zeroize(), + None => () + } + } +} + +/// Impl `Zeroize` on slices of types that can be zeroized with `Default`. /// /// This impl can eventually be optimized using an memset intrinsic, /// such as `core::intrinsics::volatile_set_memory`. For that reason the blanket