We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 413bafd + 5efe083 commit 77987baCopy full SHA for 77987ba
src/libstd/ffi/c_str.rs
@@ -326,6 +326,22 @@ impl fmt::Debug for CStr {
326
}
327
328
329
+#[stable(feature = "cstr_default", since = "1.10.0")]
330
+impl<'a> Default for &'a CStr {
331
+ fn default() -> &'a CStr {
332
+ static SLICE: &'static [c_char] = &[0];
333
+ unsafe { CStr::from_ptr(SLICE.as_ptr()) }
334
+ }
335
+}
336
+
337
338
+impl Default for CString {
339
+ fn default() -> CString {
340
+ let a: &CStr = Default::default();
341
+ a.to_owned()
342
343
344
345
#[stable(feature = "cstr_borrow", since = "1.3.0")]
346
impl Borrow<CStr> for CString {
347
fn borrow(&self) -> &CStr { self }
0 commit comments