diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 46f2d3a6418..246f868e6cb 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -173,6 +173,14 @@ impl ops::Deref for OsString { } } +#[stable(feature = "rust1", since = "1.9.0")] +impl Default for OsString { + #[inline] + fn default() -> OsString { + OsString::new() + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Debug for OsString { fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { @@ -554,6 +562,12 @@ mod tests { assert!(os_string.capacity() >= 33) } + #[test] + fn test_os_string_default() { + let os_string: OsString = Default::default(); + assert_eq!("", &os_string); + } + #[test] fn test_os_str_is_empty() { let mut os_string = OsString::new();