1
1
//! Provides [Alphabet] and constants for alphabets commonly used in the wild.
2
2
3
3
use crate :: PAD_BYTE ;
4
+ use core:: { convert, fmt} ;
4
5
#[ cfg( any( feature = "std" , test) ) ]
5
- use std:: { convert , error, fmt } ;
6
+ use std:: error;
6
7
7
8
const ALPHABET_SIZE : usize = 64 ;
8
9
@@ -43,9 +44,6 @@ impl Alphabet {
43
44
/// Create an `Alphabet` from a string of 64 unique printable ASCII bytes.
44
45
///
45
46
/// The `=` byte is not allowed as it is used for padding.
46
- ///
47
- /// The `const`-ness of this function isn't useful as of rust 1.54.0 since `const` `unwrap()`,
48
- /// etc, haven't shipped yet, but that's [on the roadmap](https://github.com/rust-lang/rust/issues/85194).
49
47
pub const fn from_str ( alphabet : & str ) -> Result < Self , ParseAlphabetError > {
50
48
let bytes = alphabet. as_bytes ( ) ;
51
49
if bytes. len ( ) != ALPHABET_SIZE {
@@ -95,7 +93,6 @@ impl Alphabet {
95
93
}
96
94
}
97
95
98
- #[ cfg( any( feature = "std" , test) ) ]
99
96
impl convert:: TryFrom < & str > for Alphabet {
100
97
type Error = ParseAlphabetError ;
101
98
@@ -117,7 +114,6 @@ pub enum ParseAlphabetError {
117
114
ReservedByte ( u8 ) ,
118
115
}
119
116
120
- #[ cfg( any( feature = "std" , test) ) ]
121
117
impl fmt:: Display for ParseAlphabetError {
122
118
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
123
119
match self {
0 commit comments