File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -574,7 +574,7 @@ impl CString {
574574 #[ stable( feature = "as_c_str" , since = "1.20.0" ) ]
575575 #[ rustc_diagnostic_item = "cstring_as_c_str" ]
576576 pub fn as_c_str ( & self ) -> & CStr {
577- & * self
577+ unsafe { CStr :: from_bytes_with_nul_unchecked ( self . as_bytes_with_nul ( ) ) }
578578 }
579579
580580 /// Converts this `CString` into a boxed [`CStr`].
@@ -705,14 +705,14 @@ impl ops::Deref for CString {
705705
706706 #[ inline]
707707 fn deref ( & self ) -> & CStr {
708- unsafe { CStr :: from_bytes_with_nul_unchecked ( self . as_bytes_with_nul ( ) ) }
708+ self . as_c_str ( )
709709 }
710710}
711711
712712#[ stable( feature = "rust1" , since = "1.0.0" ) ]
713713impl fmt:: Debug for CString {
714714 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
715- fmt:: Debug :: fmt ( & * * self , f)
715+ fmt:: Debug :: fmt ( self . as_c_str ( ) , f)
716716 }
717717}
718718
You can’t perform that action at this time.
0 commit comments