Skip to content

Commit

Permalink
zeroize: impl Zeroize for Option
Browse files Browse the repository at this point in the history
Adds a blanket impl for `Option<Z: Zeroize>`
  • Loading branch information
tony-iqlusion committed Jun 5, 2019
1 parent 94274a2 commit a6ccafd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion zeroize/src/lib.rs
Expand Up @@ -295,7 +295,19 @@ where
}
}

/// Implement `Zeroize` on slices of types that can be zeroized with `Default`.
impl<Z> Zeroize for Option<Z>
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
Expand Down

0 comments on commit a6ccafd

Please sign in to comment.