diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2023-02-06 20:47:28 +0000 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2023-02-06 20:47:28 +0000 |
| commit | 73792f35da2910620c832dfb0873212cd5af7b33 (patch) | |
| tree | 451fa4e4739311a1ba2daa1b2fd72f31c3aa2588 /src/mnemonic.rs | |
| parent | d8496d150db33f4bab4d4c9e0162d65b071aef74 (diff) | |
More idiomatic format strings, version bumps
Diffstat (limited to 'src/mnemonic.rs')
| -rw-r--r-- | src/mnemonic.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mnemonic.rs b/src/mnemonic.rs index 05d9930..432c88a 100644 --- a/src/mnemonic.rs +++ b/src/mnemonic.rs @@ -5,7 +5,7 @@ mod wordlist; pub use self::{language::Language, wordlist::WORD_COUNT}; use crate::{hash, rand}; -use anyhow::{anyhow, ensure, Result}; +use anyhow::{ensure, Context as _, Result}; use hmac::Hmac; use sha2::Sha512; use std::{ @@ -78,7 +78,7 @@ impl Mnemonic { for word in &words { let index = wordlist .search(word) - .ok_or_else(|| anyhow!("invalid BIP-0039 {} word '{}'", language, word))?; + .with_context(|| format!("invalid BIP-0039 {language} word '{word}'"))?; acc = (acc << WORD_BITS) | index; bit_offset += WORD_BITS; @@ -195,7 +195,7 @@ impl Deref for Seed { } fn mnemonic_to_byte_length(len: usize) -> Result<usize> { - ensure!(matches!(len, 12..=24), "invalid mnemonic length {}", len); + ensure!(matches!(len, 12..=24), "invalid mnemonic length {len}"); // NOTE: Derived from the BIP-0039 spec where `CS` is the checksum bit // length, `ENT` is the entropy bit length (so `8 * byte_length`) and `MS` |
