about summary refs log tree commit diff
path: root/library/core
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-09-24 23:33:27 +0200
committerGitHub <noreply@github.com>2025-09-24 23:33:27 +0200
commit6618ac7bb1caff5b1abe4795101f5c5f17603340 (patch)
tree6622bda0c1759e5ea505ddf9739f024f2bcc1fba /library/core
parent6351a634864dc48a7ac61942304cc53b271ebdeb (diff)
parenta875f7779e3c3b9023bff24b6beca08e7be0e0e8 (diff)
downloadrust-6618ac7bb1caff5b1abe4795101f5c5f17603340.tar.gz
rust-6618ac7bb1caff5b1abe4795101f5c5f17603340.zip
Rollup merge of #146950 - joboet:cstr_default, r=tgross35
core: simplify `CStr::default()`

Just use a `CStr`-literal...
Diffstat (limited to 'library/core')
-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""
     }
 }