File tree 3 files changed +6
-6
lines changed
3 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -173,7 +173,7 @@ impl FromStr for ParamsString {
173
173
type Err = Error ;
174
174
175
175
fn from_str ( s : & str ) -> Result < Self > {
176
- if s. as_bytes ( ) . len ( ) > MAX_LENGTH {
176
+ if s. len ( ) > MAX_LENGTH {
177
177
return Err ( Error :: ParamsMaxExceeded ) ;
178
178
}
179
179
@@ -201,11 +201,11 @@ impl FromStr for ParamsString {
201
201
}
202
202
203
203
let mut bytes = [ 0u8 ; MAX_LENGTH ] ;
204
- bytes[ ..s. as_bytes ( ) . len ( ) ] . copy_from_slice ( s. as_bytes ( ) ) ;
204
+ bytes[ ..s. len ( ) ] . copy_from_slice ( s. as_bytes ( ) ) ;
205
205
206
206
Ok ( Self ( Buffer {
207
207
bytes,
208
- length : s. as_bytes ( ) . len ( ) as u8 ,
208
+ length : s. len ( ) as u8 ,
209
209
} ) )
210
210
}
211
211
}
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ impl<'a> Salt<'a> {
103
103
/// Create a [`Salt`] from the given B64-encoded input string, validating
104
104
/// [`Salt::MIN_LENGTH`] and [`Salt::MAX_LENGTH`] restrictions.
105
105
pub fn from_b64 ( input : & ' a str ) -> Result < Self > {
106
- let length = input. as_bytes ( ) . len ( ) ;
106
+ let length = input. len ( ) ;
107
107
108
108
if length < Self :: MIN_LENGTH {
109
109
return Err ( Error :: SaltInvalid ( InvalidValue :: TooShort ) ) ;
@@ -215,7 +215,7 @@ impl SaltString {
215
215
// Assert `s` parses successfully as a `Salt`
216
216
Salt :: from_b64 ( s) ?;
217
217
218
- let len = s. as_bytes ( ) . len ( ) ;
218
+ let len = s. len ( ) ;
219
219
220
220
let mut bytes = [ 0u8 ; Salt :: MAX_LENGTH ] ;
221
221
bytes[ ..len] . copy_from_slice ( s. as_bytes ( ) ) ;
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ impl<'a> Value<'a> {
50
50
/// Parse a [`Value`] from the provided `str`, validating it according to
51
51
/// the PHC string format's rules.
52
52
pub fn new ( input : & ' a str ) -> Result < Self > {
53
- if input. as_bytes ( ) . len ( ) > Self :: MAX_LENGTH {
53
+ if input. len ( ) > Self :: MAX_LENGTH {
54
54
return Err ( Error :: ParamValueInvalid ( InvalidValue :: TooLong ) ) ;
55
55
}
56
56
You can’t perform that action at this time.
0 commit comments