File tree Expand file tree Collapse file tree 2 files changed +3
-8
lines changed Expand file tree Collapse file tree 2 files changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -970,17 +970,14 @@ impl Default for Rc<CStr> {
970
970
/// This may or may not share an allocation with other Rcs on the same thread.
971
971
#[ inline]
972
972
fn default ( ) -> Self {
973
- let rc = Rc :: < [ u8 ] > :: from ( * b"\0 " ) ;
974
- // `[u8]` has the same layout as `CStr`, and it is `NUL` terminated.
975
- unsafe { Rc :: from_raw ( Rc :: into_raw ( rc) as * const CStr ) }
973
+ Rc :: from ( c"" )
976
974
}
977
975
}
978
976
979
977
#[ stable( feature = "default_box_extra" , since = "1.17.0" ) ]
980
978
impl Default for Box < CStr > {
981
979
fn default ( ) -> Box < CStr > {
982
- let boxed: Box < [ u8 ] > = Box :: from ( [ 0 ] ) ;
983
- unsafe { Box :: from_raw ( Box :: into_raw ( boxed) as * mut CStr ) }
980
+ Box :: from ( c"" )
984
981
}
985
982
}
986
983
Original file line number Diff line number Diff line change @@ -179,9 +179,7 @@ impl fmt::Debug for CStr {
179
179
impl Default for & CStr {
180
180
#[ inline]
181
181
fn default ( ) -> Self {
182
- const SLICE : & [ c_char ] = & [ 0 ] ;
183
- // SAFETY: `SLICE` is indeed pointing to a valid nul-terminated string.
184
- unsafe { CStr :: from_ptr ( SLICE . as_ptr ( ) ) }
182
+ c""
185
183
}
186
184
}
187
185
You can’t perform that action at this time.
0 commit comments