Skip to content

Commit 2750e74

Browse files
Merge pull request #219 from iqlusioninc/zeroize/option-support
zeroize: impl Zeroize for Option
2 parents 94274a2 + cfe5107 commit 2750e74

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

zeroize/src/lib.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,19 @@ where
295295
}
296296
}
297297

298-
/// Implement `Zeroize` on slices of types that can be zeroized with `Default`.
298+
impl<Z> Zeroize for Option<Z>
299+
where
300+
Z: Zeroize,
301+
{
302+
fn zeroize(&mut self) {
303+
match self {
304+
Some(value) => value.zeroize(),
305+
None => (),
306+
}
307+
}
308+
}
309+
310+
/// Impl `Zeroize` on slices of types that can be zeroized with `Default`.
299311
///
300312
/// This impl can eventually be optimized using an memset intrinsic,
301313
/// such as `core::intrinsics::volatile_set_memory`. For that reason the blanket

0 commit comments

Comments
 (0)