Implement Default for OsString

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

View File

@ -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();