Skip to content

Commit d94d4be

Browse files
authored
Rollup merge of #146950 - joboet:cstr_default, r=tgross35
core: simplify `CStr::default()` Just use a `CStr`-literal...
2 parents d42825a + aa53782 commit d94d4be

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

library/core/src/ffi/c_str.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,7 @@ impl fmt::Debug for CStr {
179179
impl Default for &CStr {
180180
#[inline]
181181
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""
185183
}
186184
}
187185

0 commit comments

Comments
 (0)