Skip to content

Commit aa5afb0

Browse files
committed
Implement Default for OsStr
1 parent 08eaf07 commit aa5afb0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/libstd/ffi/os_str.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,14 @@ impl OsStr {
310310
}
311311
}
312312

313+
#[stable(feature = "rust1", since = "1.9.0")]
314+
impl<'a> Default for &'a OsStr {
315+
#[inline]
316+
fn default() -> &'a OsStr {
317+
""
318+
}
319+
}
320+
313321
#[stable(feature = "rust1", since = "1.0.0")]
314322
impl PartialEq for OsStr {
315323
fn eq(&self, other: &OsStr) -> bool {
@@ -591,4 +599,10 @@ mod tests {
591599
os_string.clear();
592600
assert_eq!(0, os_string.len());
593601
}
602+
603+
#[test]
604+
fn test_os_str_default() {
605+
let os_str: &OsStr = Default::default();
606+
assert_eq!("", os_str);
607+
}
594608
}

0 commit comments

Comments
 (0)