2929#[ cfg( any( test, feature = "std" ) ) ]
3030pub extern crate core;
3131
32+ #[ cfg( feature = "alloc" ) ]
3233extern crate alloc;
3334
3435extern crate bitcoin_hashes;
3536
36- #[ cfg( feature = "std " ) ]
37+ #[ cfg( feature = "unicode-normalization " ) ]
3738extern crate unicode_normalization;
3839
3940#[ cfg( feature = "rand" ) ]
@@ -43,16 +44,16 @@ pub extern crate rand_core;
4344#[ cfg( feature = "serde" ) ]
4445pub extern crate serde;
4546
47+ #[ cfg( feature = "alloc" ) ]
48+ use alloc:: { borrow:: Cow , string:: ToString , vec:: Vec } ;
4649use core:: { fmt, str} ;
4750
48- #[ cfg( feature = "std" ) ]
49- use std:: borrow:: Cow ;
5051#[ cfg( feature = "std" ) ]
5152use std:: error;
5253
5354use bitcoin_hashes:: { sha256, Hash } ;
5455
55- #[ cfg( feature = "std " ) ]
56+ #[ cfg( feature = "unicode-normalization " ) ]
5657use unicode_normalization:: UnicodeNormalization ;
5758
5859#[ cfg( feature = "zeroize" ) ]
@@ -95,7 +96,7 @@ impl AmbiguousLanguages {
9596 }
9697
9798 /// Returns a vector of the possible languages.
98- #[ cfg( feature = "std " ) ]
99+ #[ cfg( feature = "alloc " ) ]
99100 pub fn to_vec ( & self ) -> Vec < Language > {
100101 self . iter ( ) . collect ( )
101102 }
@@ -183,7 +184,7 @@ impl Mnemonic {
183184 /// Performing this on a [Cow] means that all allocations for normalization
184185 /// can be avoided for languages without special UTF8 characters.
185186 #[ inline]
186- #[ cfg( feature = "std " ) ]
187+ #[ cfg( feature = "unicode-normalization " ) ]
187188 pub fn normalize_utf8_cow < ' a > ( cow : & mut Cow < ' a , str > ) {
188189 let is_nfkd = unicode_normalization:: is_nfkd_quick ( cow. as_ref ( ) . chars ( ) ) ;
189190 if is_nfkd != unicode_normalization:: IsNormalized :: Yes {
@@ -506,7 +507,7 @@ impl Mnemonic {
506507 }
507508
508509 /// Parse a mnemonic in the given language.
509- #[ cfg( feature = "std " ) ]
510+ #[ cfg( feature = "unicode-normalization " ) ]
510511 pub fn parse_in < ' a , S : Into < Cow < ' a , str > > > (
511512 language : Language ,
512513 s : S ,
@@ -517,7 +518,7 @@ impl Mnemonic {
517518 }
518519
519520 /// Parse a mnemonic and detect the language from the enabled languages.
520- #[ cfg( feature = "std " ) ]
521+ #[ cfg( feature = "unicode-normalization " ) ]
521522 pub fn parse < ' a , S : Into < Cow < ' a , str > > > ( s : S ) -> Result < Mnemonic , Error > {
522523 let mut cow = s. into ( ) ;
523524 Mnemonic :: normalize_utf8_cow ( & mut cow) ;
@@ -547,7 +548,7 @@ impl Mnemonic {
547548 }
548549
549550 /// Convert to seed bytes.
550- #[ cfg( feature = "std " ) ]
551+ #[ cfg( feature = "unicode-normalization " ) ]
551552 pub fn to_seed < ' a , P : Into < Cow < ' a , str > > > ( & self , passphrase : P ) -> [ u8 ; 64 ] {
552553 let normalized_passphrase = {
553554 let mut cow = passphrase. into ( ) ;
@@ -596,7 +597,7 @@ impl Mnemonic {
596597 }
597598
598599 /// Convert the mnemonic back to the entropy used to generate it.
599- #[ cfg( feature = "std " ) ]
600+ #[ cfg( feature = "alloc " ) ]
600601 pub fn to_entropy ( & self ) -> Vec < u8 > {
601602 let ( arr, len) = self . to_entropy_array ( ) ;
602603 arr[ 0 ..len] . to_vec ( )
@@ -648,11 +649,11 @@ impl str::FromStr for Mnemonic {
648649 type Err = Error ;
649650
650651 fn from_str ( s : & str ) -> Result < Mnemonic , Error > {
651- #[ cfg( feature = "std " ) ]
652+ #[ cfg( feature = "unicode-normalization " ) ]
652653 {
653654 Mnemonic :: parse ( s)
654655 }
655- #[ cfg( not( feature = "std " ) ) ]
656+ #[ cfg( not( feature = "unicode-normalization " ) ) ]
656657 {
657658 Mnemonic :: parse_normalized ( s)
658659 }
@@ -871,7 +872,7 @@ mod tests {
871872 mnemonic_str
872873 ) ;
873874
874- #[ cfg( feature = "std " ) ]
875+ #[ cfg( feature = "unicode-normalization " ) ]
875876 {
876877 assert_eq ! ( & mnemonic. to_string( ) , mnemonic_str, "failed vector: {}" , mnemonic_str) ;
877878 assert_eq ! (
0 commit comments