Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/libstd/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ impl ops::Deref for OsString {
}
}

#[stable(feature = "rust1", since = "1.9.0")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a new feature name. For example osstring_default (use same for both). Version 1.9.0 is ok I think since we are still in version 1.9.0 in the nightly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed. Thanks!

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> {
Expand Down Expand Up @@ -302,6 +310,14 @@ impl OsStr {
}
}

#[stable(feature = "rust1", since = "1.9.0")]
impl<'a> Default for &'a OsStr {
#[inline]
fn default() -> &'a OsStr {
""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this compiles, but OsStr::new("") should.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Fixed.

}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl PartialEq for OsStr {
fn eq(&self, other: &OsStr) -> bool {
Expand Down Expand Up @@ -554,6 +570,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();
Expand All @@ -577,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);
}
}