@@ -116,7 +116,7 @@ impl AsciiString {
116116 {
117117 let mut bytes = bytes. into ( ) ;
118118 // SAFETY: The caller guarantees all bytes are valid ascii bytes.
119- let ptr = bytes. as_mut_ptr ( ) as * mut AsciiChar ;
119+ let ptr = bytes. as_mut_ptr ( ) . cast :: < AsciiChar > ( ) ;
120120 let length = bytes. len ( ) ;
121121 let capacity = bytes. capacity ( ) ;
122122 mem:: forget ( bytes) ;
@@ -169,7 +169,7 @@ impl AsciiString {
169169 /// ```
170170 #[ inline]
171171 pub fn push_str ( & mut self , string : & AsciiStr ) {
172- self . vec . extend ( string. chars ( ) )
172+ self . vec . extend ( string. chars ( ) ) ;
173173 }
174174
175175 /// Inserts the given ASCII string at the given place in this ASCII string buffer.
@@ -220,7 +220,7 @@ impl AsciiString {
220220 /// ```
221221 #[ inline]
222222 pub fn reserve ( & mut self , additional : usize ) {
223- self . vec . reserve ( additional)
223+ self . vec . reserve ( additional) ;
224224 }
225225
226226 /// Reserves the minimum capacity for exactly `additional` more bytes to be inserted in the
@@ -243,7 +243,7 @@ impl AsciiString {
243243 #[ inline]
244244
245245 pub fn reserve_exact ( & mut self , additional : usize ) {
246- self . vec . reserve_exact ( additional)
246+ self . vec . reserve_exact ( additional) ;
247247 }
248248
249249 /// Shrinks the capacity of this ASCII string buffer to match it's length.
@@ -261,7 +261,7 @@ impl AsciiString {
261261 #[ inline]
262262
263263 pub fn shrink_to_fit ( & mut self ) {
264- self . vec . shrink_to_fit ( )
264+ self . vec . shrink_to_fit ( ) ;
265265 }
266266
267267 /// Adds the given ASCII character to the end of the ASCII string.
@@ -278,7 +278,7 @@ impl AsciiString {
278278 #[ inline]
279279
280280 pub fn push ( & mut self , ch : AsciiChar ) {
281- self . vec . push ( ch)
281+ self . vec . push ( ch) ;
282282 }
283283
284284 /// Shortens a ASCII string to the specified length.
@@ -296,7 +296,7 @@ impl AsciiString {
296296 #[ inline]
297297
298298 pub fn truncate ( & mut self , new_len : usize ) {
299- self . vec . truncate ( new_len)
299+ self . vec . truncate ( new_len) ;
300300 }
301301
302302 /// Removes the last character from the ASCII string buffer and returns it.
@@ -357,7 +357,7 @@ impl AsciiString {
357357 #[ inline]
358358
359359 pub fn insert ( & mut self , idx : usize , ch : AsciiChar ) {
360- self . vec . insert ( idx, ch)
360+ self . vec . insert ( idx, ch) ;
361361 }
362362
363363 /// Returns the number of bytes in this ASCII string.
@@ -402,14 +402,15 @@ impl AsciiString {
402402 #[ inline]
403403
404404 pub fn clear ( & mut self ) {
405- self . vec . clear ( )
405+ self . vec . clear ( ) ;
406406 }
407407
408408 /// Converts this [`AsciiString`] into a [`Box`]`<`[`AsciiStr`]`>`.
409409 ///
410410 /// This will drop any excess capacity
411411 #[ cfg( feature = "alloc" ) ]
412412 #[ inline]
413+ #[ must_use]
413414 pub fn into_boxed_ascii_str ( self ) -> Box < AsciiStr > {
414415 let slice = self . vec . into_boxed_slice ( ) ;
415416 Box :: from ( slice)
@@ -490,15 +491,17 @@ impl From<Vec<AsciiChar>> for AsciiString {
490491impl From < AsciiChar > for AsciiString {
491492 #[ inline]
492493 fn from ( ch : AsciiChar ) -> Self {
493- AsciiString { vec : vec ! [ ch] }
494+ AsciiString { vec : vec ! [ ch] }
494495 }
495496}
496497
498+ // FIXME? Turn this into a `From` impl
499+ #[ allow( clippy:: from_over_into) ]
497500impl Into < Vec < u8 > > for AsciiString {
498501 fn into ( mut self ) -> Vec < u8 > {
499502 // SAFETY: All ascii bytes are valid `u8`, as we are `repr(u8)`.
500503 // Note: We forget `self` to avoid `self.vec` from being deallocated.
501- let ptr = self . vec . as_mut_ptr ( ) as * mut u8 ;
504+ let ptr = self . vec . as_mut_ptr ( ) . cast :: < u8 > ( ) ;
502505 let length = self . vec . len ( ) ;
503506 let capacity = self . vec . capacity ( ) ;
504507 mem:: forget ( self ) ;
@@ -520,10 +523,12 @@ impl<'a> From<&'a AsciiStr> for AsciiString {
520523impl < ' a > From < & ' a [ AsciiChar ] > for AsciiString {
521524 #[ inline]
522525 fn from ( s : & ' a [ AsciiChar ] ) -> AsciiString {
523- s. iter ( ) . cloned ( ) . collect ( )
526+ s. iter ( ) . copied ( ) . collect ( )
524527 }
525528}
526529
530+ // FIXME? Turn this into a `From` impl
531+ #[ allow( clippy:: from_over_into) ]
527532impl Into < String > for AsciiString {
528533 #[ inline]
529534 fn into ( self ) -> String {
@@ -666,7 +671,7 @@ impl<A: AsRef<AsciiStr>> Extend<A> for AsciiString {
666671 let ( lower_bound, _) = iterator. size_hint ( ) ;
667672 self . reserve ( lower_bound) ;
668673 for item in iterator {
669- self . push_str ( item. as_ref ( ) )
674+ self . push_str ( item. as_ref ( ) ) ;
670675 }
671676 }
672677}
@@ -899,7 +904,7 @@ impl<'a> IntoAsciiString for &'a CStr {
899904 . map_err ( |FromAsciiError { error, owner } | FromAsciiError {
900905 // SAFETY: We don't discard the NULL byte from the original
901906 // string, so we ensure that it's null terminated
902- owner : unsafe { CStr :: from_ptr ( owner. as_ptr ( ) as * const _ ) } ,
907+ owner : unsafe { CStr :: from_ptr ( owner. as_ptr ( ) . cast ( ) ) } ,
903908 error,
904909 } )
905910 . map ( |mut s| {
@@ -954,7 +959,7 @@ mod tests {
954959 use alloc:: vec:: Vec ;
955960 #[ cfg( feature = "std" ) ]
956961 use std:: ffi:: CString ;
957- use :: { AsciiChar , AsciiStr } ;
962+ use { AsciiChar , AsciiStr } ;
958963
959964 #[ test]
960965 fn into_string ( ) {
@@ -965,7 +970,7 @@ mod tests {
965970 #[ test]
966971 fn into_bytes ( ) {
967972 let v = AsciiString :: from_ascii ( & [ 40_u8 , 32 , 59 ] [ ..] ) . unwrap ( ) ;
968- assert_eq ! ( Into :: <Vec <u8 >>:: into( v) , vec![ 40_u8 , 32 , 59 ] )
973+ assert_eq ! ( Into :: <Vec <u8 >>:: into( v) , vec![ 40_u8 , 32 , 59 ] ) ;
969974 }
970975
971976 #[ test]
0 commit comments