about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorjoboet <jonasboettiger@icloud.com>2025-09-24 00:50:36 +0200
committerjoboet <jonasboettiger@icloud.com>2025-09-24 00:50:36 +0200
commitaa537824c40437d11d32c66fe16d4764b072c094 (patch)
treeb6942a6e45b766e4d793e70f423ea04e019f371e /library/core/src
parent975e6c8fec280816d24fbde6b8dfe19620f2efe6 (diff)
downloadrust-aa537824c40437d11d32c66fe16d4764b072c094.tar.gz
rust-aa537824c40437d11d32c66fe16d4764b072c094.zip
core: simplify `CStr::default()`
Just use a `CStr`-literal...
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/ffi/c_str.rs4
1 files changed, 1 insertions, 3 deletions
diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs
index d0b53e3a237..09d9b160700 100644
--- a/library/core/src/ffi/c_str.rs
+++ b/library/core/src/ffi/c_str.rs
@@ -179,9 +179,7 @@ impl fmt::Debug for CStr {
 impl Default for &CStr {
     #[inline]
     fn default() -> Self {
-        const SLICE: &[c_char] = &[0];
-        // SAFETY: `SLICE` is indeed pointing to a valid nul-terminated string.
-        unsafe { CStr::from_ptr(SLICE.as_ptr()) }
+        c""
     }
 }