Skip to content

Commit 08eaf07

Browse files
committed
Implement Default for OsString
1 parent 690f160 commit 08eaf07

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
@@ -173,6 +173,14 @@ impl ops::Deref for OsString {
173173
}
174174
}
175175

176+
#[stable(feature = "rust1", since = "1.9.0")]
177+
impl Default for OsString {
178+
#[inline]
179+
fn default() -> OsString {
180+
OsString::new()
181+
}
182+
}
183+
176184
#[stable(feature = "rust1", since = "1.0.0")]
177185
impl Debug for OsString {
178186
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
@@ -554,6 +562,12 @@ mod tests {
554562
assert!(os_string.capacity() >= 33)
555563
}
556564

565+
#[test]
566+
fn test_os_string_default() {
567+
let os_string: OsString = Default::default();
568+
assert_eq!("", &os_string);
569+
}
570+
557571
#[test]
558572
fn test_os_str_is_empty() {
559573
let mut os_string = OsString::new();

0 commit comments

Comments
 (0)