Implement Default for OsStr

This commit is contained in:
Wangshan Lu 2016-03-22 00:45:36 +08:00
parent 08eaf07dbc
commit aa5afb0c17

View File

@ -310,6 +310,14 @@ impl OsStr {
}
}
#[stable(feature = "rust1", since = "1.9.0")]
impl<'a> Default for &'a OsStr {
#[inline]
fn default() -> &'a OsStr {
""
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl PartialEq for OsStr {
fn eq(&self, other: &OsStr) -> bool {
@ -591,4 +599,10 @@ mod tests {
os_string.clear();
assert_eq!(0, os_string.len());
}
#[test]
fn test_os_str_default() {
let os_str: &OsStr = Default::default();
assert_eq!("", os_str);
}
}