The MSRV test on master was failing for a while. Since MSRV is
the reason to keep unicode-normalization pinned I fixed it to
demonstrate that even without pinning downstream consumers can
maintain the current MSRV.
We use a range dependency for `bitcoin_hashes`, the different allowed
versions each have a different MSRV, which implies using each changes
the MSRV of `bip39`.
fixing:
error: the item `ToString` is imported redundantly
--> src/lib.rs:48:26
error: the item `Vec` is imported redundantly
--> src/lib.rs:48:44
error: could not compile `bip39` (lib) due to 2 previous errors
Re-exports from `rand` crate shall be used. Otherwise trait bounds in
`Mnemonic::generate_in_with` for `rand::thread_rng` object can get
unsatisfied if crate deps get ouf of sync.
This commit is fixing following errors:
```
error[E0277]: the trait bound `ThreadRng: rand_core::RngCore` is not satisfied
--> /home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bip39-2.0.0/src/lib.rs:292:30
|
292 | Mnemonic::generate_in_with(&mut rand::thread_rng(), language, word_count)
| -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^ the trait `rand_core::RngCore` is not implemented for `ThreadRng`
| |
| required by a bound introduced by this call
|::
= help: the following other types implement trait `rand_core::RngCore`:
...
note: required by a bound in `Mnemonic::generate_in_with`
--> /home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bip39-2.0.0/src/lib.rs:266:6
|
260 | pub fn generate_in_with<R>(
| ---------------- required by a bound in this associated function
...
266 | R: rand_core::RngCore + rand_core::CryptoRng,
| ^^^^^^^^^^^^^^^^^^ required by this bound in `Mnemonic::generate_in_with`
```
```
error[E0277]: the trait bound `ThreadRng: rand_core::CryptoRng` is not satisfied
--> /home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bip39-2.0.0/src/lib.rs:292:30
|
292 | Mnemonic::generate_in_with(&mut rand::thread_rng(), language, word_count)
| -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^ the trait `rand_core::CryptoRng` is not implemented for `ThreadRng`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `rand_core::CryptoRng`:
...
note: required by a bound in `Mnemonic::generate_in_with`
--> /home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bip39-2.0.0/src/lib.rs:266:27
|
260 | pub fn generate_in_with<R>(
| ---------------- required by a bound in this associated function
...
266 | R: rand_core::RngCore + rand_core::CryptoRng,
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `Mnemonic::generate_in_with`
```
Co-authored-by: Tobin C. Harding <me@tobin.cc>
This commit introduces the `alloc` feature.
The alloc feature is intended to use in no-std environments which are allowed to
use alloc. New feature enables:
- the unicode-normalization, and all related methods (parse_in,normalize_utf8_cow,parse,to_seed)
- to_entropy() method as Vec is available in alloc,
For languages that support it, the implementation of
`Language::find_word` now uses binary search to find the word index. For
languages that do not support it, the old linear search is used.
This substantially improves the runtime performance of
`Language::find_word`. For affected languages, average lookup rate is
increased ~25x on release builds and ~100x on debug builds.
To follow the convention for Rust iterators, for example, in `str`
the method for a char iterator is `chars` not `char_iter`.
Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>