Use `zeroize_derive` feature instead of impl zeroize

This commit is contained in:
Praveen Perera 2021-04-19 12:08:04 -04:00
parent a298344178
commit bb0f63298a
No known key found for this signature in database
GPG Key ID: FA763323122DA6E9
3 changed files with 9 additions and 6 deletions

View File

@ -46,7 +46,7 @@ rand_core = "0.4.0"
unicode-normalization = { version = "=0.1.9", optional = true }
rand = { version = "0.6.0", optional = true }
serde = { version = "1.0", default-features = false, optional = true }
zeroize = {version = "1.2", optional = true}
zeroize = {version = "1.2", features = ["zeroize_derive"], optional = true}
[dev-dependencies]
rand = { version = "0.6.0", optional = false }

View File

@ -55,6 +55,12 @@ pub enum Language {
Spanish,
}
impl Default for Language {
fn default() -> Self {
Language::English
}
}
impl Language {
/// The list of supported languages.
/// Language support is managed by compile features.

View File

@ -157,6 +157,7 @@ impl error::Error for Error {}
///
/// Supported number of words are 12, 18 and 24.
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "zeroize", derive(Zeroize), zeroize(drop))]
pub struct Mnemonic {
/// The language the mnemonic.
lang: Language,
@ -166,11 +167,7 @@ pub struct Mnemonic {
}
#[cfg(feature = "zeroize")]
impl Zeroize for Mnemonic {
fn zeroize(&mut self) {
self.words.zeroize()
}
}
impl zeroize::DefaultIsZeroes for Language {}
serde_string_impl!(Mnemonic, "a BIP-39 Mnemonic Code");