diff --git a/Cargo.toml b/Cargo.toml index 4d7b5d8..9799420 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } diff --git a/src/language/mod.rs b/src/language/mod.rs index 10e0a44..0ea9dc6 100644 --- a/src/language/mod.rs +++ b/src/language/mod.rs @@ -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. diff --git a/src/lib.rs b/src/lib.rs index 51f7226..1aedcd7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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");