File tree 1 file changed +3
-3
lines changed
1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -574,7 +574,7 @@ impl CString {
574
574
#[ stable( feature = "as_c_str" , since = "1.20.0" ) ]
575
575
#[ rustc_diagnostic_item = "cstring_as_c_str" ]
576
576
pub fn as_c_str ( & self ) -> & CStr {
577
- & * self
577
+ unsafe { CStr :: from_bytes_with_nul_unchecked ( self . as_bytes_with_nul ( ) ) }
578
578
}
579
579
580
580
/// Converts this `CString` into a boxed [`CStr`].
@@ -705,14 +705,14 @@ impl ops::Deref for CString {
705
705
706
706
#[ inline]
707
707
fn deref ( & self ) -> & CStr {
708
- unsafe { CStr :: from_bytes_with_nul_unchecked ( self . as_bytes_with_nul ( ) ) }
708
+ self . as_c_str ( )
709
709
}
710
710
}
711
711
712
712
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
713
713
impl fmt:: Debug for CString {
714
714
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
715
- fmt:: Debug :: fmt ( & * * self , f)
715
+ fmt:: Debug :: fmt ( self . as_c_str ( ) , f)
716
716
}
717
717
}
718
718
You can’t perform that action at this time.
0 commit comments