@@ -498,16 +498,14 @@ impl From<AsciiChar> for AsciiString {
498
498
}
499
499
}
500
500
501
- // FIXME? Turn this into a `From` impl
502
- #[ allow( clippy:: from_over_into) ]
503
- impl Into < Vec < u8 > > for AsciiString {
504
- fn into ( mut self ) -> Vec < u8 > {
501
+ impl From < AsciiString > for Vec < u8 > {
502
+ fn from ( mut s : AsciiString ) -> Vec < u8 > {
505
503
// SAFETY: All ascii bytes are valid `u8`, as we are `repr(u8)`.
506
504
// Note: We forget `self` to avoid `self.vec` from being deallocated.
507
- let ptr = self . vec . as_mut_ptr ( ) . cast :: < u8 > ( ) ;
508
- let length = self . vec . len ( ) ;
509
- let capacity = self . vec . capacity ( ) ;
510
- mem:: forget ( self ) ;
505
+ let ptr = s . vec . as_mut_ptr ( ) . cast :: < u8 > ( ) ;
506
+ let length = s . vec . len ( ) ;
507
+ let capacity = s . vec . capacity ( ) ;
508
+ mem:: forget ( s ) ;
511
509
512
510
// SAFETY: We guarantee all invariants due to getting `ptr`, `length`
513
511
// and `capacity` from a `Vec`. We also guarantee `ptr` is valid
@@ -516,10 +514,9 @@ impl Into<Vec<u8>> for AsciiString {
516
514
}
517
515
}
518
516
519
- #[ allow( clippy:: from_over_into) ]
520
- impl Into < Vec < AsciiChar > > for AsciiString {
521
- fn into ( self ) -> Vec < AsciiChar > {
522
- self . vec
517
+ impl From < AsciiString > for Vec < AsciiChar > {
518
+ fn from ( s : AsciiString ) -> Vec < AsciiChar > {
519
+ s. vec
523
520
}
524
521
}
525
522
@@ -537,13 +534,11 @@ impl<'a> From<&'a [AsciiChar]> for AsciiString {
537
534
}
538
535
}
539
536
540
- // FIXME? Turn this into a `From` impl
541
- #[ allow( clippy:: from_over_into) ]
542
- impl Into < String > for AsciiString {
537
+ impl From < AsciiString > for String {
543
538
#[ inline]
544
- fn into ( self ) -> String {
539
+ fn from ( s : AsciiString ) -> String {
545
540
// SAFETY: All ascii bytes are `utf8`.
546
- unsafe { String :: from_utf8_unchecked ( self . into ( ) ) }
541
+ unsafe { String :: from_utf8_unchecked ( s . into ( ) ) }
547
542
}
548
543
}
549
544
@@ -561,19 +556,17 @@ impl From<AsciiString> for Box<AsciiStr> {
561
556
}
562
557
}
563
558
564
- #[ allow( clippy:: from_over_into) ]
565
- impl Into < Rc < AsciiStr > > for AsciiString {
566
- fn into ( self ) -> Rc < AsciiStr > {
567
- let var: Rc < [ AsciiChar ] > = self . vec . into ( ) ;
559
+ impl From < AsciiString > for Rc < AsciiStr > {
560
+ fn from ( s : AsciiString ) -> Rc < AsciiStr > {
561
+ let var: Rc < [ AsciiChar ] > = s. vec . into ( ) ;
568
562
// SAFETY: AsciiStr is repr(transparent) and thus has the same layout as [AsciiChar]
569
563
unsafe { Rc :: from_raw ( Rc :: into_raw ( var) as * const AsciiStr ) }
570
564
}
571
565
}
572
566
573
- #[ allow( clippy:: from_over_into) ]
574
- impl Into < Arc < AsciiStr > > for AsciiString {
575
- fn into ( self ) -> Arc < AsciiStr > {
576
- let var: Arc < [ AsciiChar ] > = self . vec . into ( ) ;
567
+ impl From < AsciiString > for Arc < AsciiStr > {
568
+ fn from ( s : AsciiString ) -> Arc < AsciiStr > {
569
+ let var: Arc < [ AsciiChar ] > = s. vec . into ( ) ;
577
570
// SAFETY: AsciiStr is repr(transparent) and thus has the same layout as [AsciiChar]
578
571
unsafe { Arc :: from_raw ( Arc :: into_raw ( var) as * const AsciiStr ) }
579
572
}
0 commit comments