Skip to content

Commit 0250302

Browse files
committed
Implement PartialEq between &str and OsString
Allows for example `os_string == "something"`
1 parent 6e5e63a commit 0250302

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/libstd/ffi/os_str.rs

+14
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,20 @@ impl PartialEq<OsString> for str {
417417
}
418418
}
419419

420+
#[stable(feature = "rust1", since = "1.28.0")]
421+
impl<'a> PartialEq<&'a str> for OsString {
422+
fn eq(&self, other: &&'a str) -> bool {
423+
**self == **other
424+
}
425+
}
426+
427+
#[stable(feature = "rust1", since = "1.28.0")]
428+
impl<'a> PartialEq<OsString> for &'a str {
429+
fn eq(&self, other: &OsString) -> bool {
430+
**other == **self
431+
}
432+
}
433+
420434
#[stable(feature = "rust1", since = "1.0.0")]
421435
impl Eq for OsString {}
422436

0 commit comments

Comments
 (0)