We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Default
Box<CStr>
Rc<CStr>
1 parent aa53782 commit a875f77Copy full SHA for a875f77
library/alloc/src/ffi/c_str.rs
@@ -970,17 +970,14 @@ impl Default for Rc<CStr> {
970
/// This may or may not share an allocation with other Rcs on the same thread.
971
#[inline]
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) }
+ Rc::from(c"")
976
}
977
978
979
#[stable(feature = "default_box_extra", since = "1.17.0")]
980
impl Default for Box<CStr> {
981
fn default() -> Box<CStr> {
982
- let boxed: Box<[u8]> = Box::from([0]);
983
- unsafe { Box::from_raw(Box::into_raw(boxed) as *mut CStr) }
+ Box::from(c"")
984
985
986
0 commit comments