@@ -27,7 +27,7 @@ pub struct Alphabet {
27
27
impl Alphabet {
28
28
/// Performs no checks so that it can be const.
29
29
/// Used only for known-valid strings.
30
- const fn from_str_unchecked ( alphabet : & str ) -> Alphabet {
30
+ const fn from_str_unchecked ( alphabet : & str ) -> Self {
31
31
let mut symbols = [ 0_u8 ; ALPHABET_SIZE ] ;
32
32
let source_bytes = alphabet. as_bytes ( ) ;
33
33
@@ -38,7 +38,7 @@ impl Alphabet {
38
38
index += 1 ;
39
39
}
40
40
41
- Alphabet { symbols }
41
+ Self { symbols }
42
42
}
43
43
44
44
/// Create an `Alphabet` from a string of 64 unique printable ASCII bytes.
@@ -97,7 +97,7 @@ impl convert::TryFrom<&str> for Alphabet {
97
97
type Error = ParseAlphabetError ;
98
98
99
99
fn try_from ( value : & str ) -> Result < Self , Self :: Error > {
100
- Alphabet :: from_str ( value)
100
+ Self :: from_str ( value)
101
101
}
102
102
}
103
103
@@ -117,10 +117,10 @@ pub enum ParseAlphabetError {
117
117
impl fmt:: Display for ParseAlphabetError {
118
118
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
119
119
match self {
120
- ParseAlphabetError :: InvalidLength => write ! ( f, "Invalid length - must be 64 bytes" ) ,
121
- ParseAlphabetError :: DuplicatedByte ( b) => write ! ( f, "Duplicated byte: {:#04x}" , b) ,
122
- ParseAlphabetError :: UnprintableByte ( b) => write ! ( f, "Unprintable byte: {:#04x}" , b) ,
123
- ParseAlphabetError :: ReservedByte ( b) => write ! ( f, "Reserved byte: {:#04x}" , b) ,
120
+ Self :: InvalidLength => write ! ( f, "Invalid length - must be 64 bytes" ) ,
121
+ Self :: DuplicatedByte ( b) => write ! ( f, "Duplicated byte: {:#04x}" , b) ,
122
+ Self :: UnprintableByte ( b) => write ! ( f, "Unprintable byte: {:#04x}" , b) ,
123
+ Self :: ReservedByte ( b) => write ! ( f, "Reserved byte: {:#04x}" , b) ,
124
124
}
125
125
}
126
126
}
@@ -238,6 +238,6 @@ mod tests {
238
238
STANDARD ,
239
239
Alphabet :: try_from( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" )
240
240
. unwrap( )
241
- )
241
+ ) ;
242
242
}
243
243
}
0 commit comments