diff --git a/src/raw/cstr.rs b/src/raw/cstr.rs index 8db13fcc..e3d221f7 100644 --- a/src/raw/cstr.rs +++ b/src/raw/cstr.rs @@ -166,6 +166,12 @@ impl<'a> From<&'a CStr> for &'a str { } } +impl Default for &CStr { + fn default() -> Self { + cstr!("") + } +} + #[cfg(feature = "serde")] impl serde::Serialize for &CStr { fn serialize(&self, serializer: S) -> std::result::Result @@ -349,6 +355,14 @@ impl std::hash::Hash for CString { } } +impl Default for CString { + fn default() -> Self { + Self { + data: String::new(), + } + } +} + #[cfg(feature = "serde")] impl serde::Serialize for CString { fn serialize(&self, serializer: S) -> std::result::Result