about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorGabriel Majeri <gabriel.majeri6@gmail.com>2018-05-29 19:16:49 +0300
committerGabriel Majeri <gabriel.majeri6@gmail.com>2018-06-29 14:50:00 +0300
commit02503029b83a295f1a03160472556fea491491f1 (patch)
tree2d6df9e06e7464d80ff780c580b4dcd3bc2e9079 /src/libstd
parent6e5e63a48c3be7de2faf914c2a9e194ff7cede9e (diff)
downloadrust-02503029b83a295f1a03160472556fea491491f1.tar.gz
rust-02503029b83a295f1a03160472556fea491491f1.zip
Implement PartialEq between &str and OsString
Allows for example `os_string == "something"`
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/ffi/os_str.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs
index 0a3148029d0..1940a1da8a0 100644
--- a/src/libstd/ffi/os_str.rs
+++ b/src/libstd/ffi/os_str.rs
@@ -417,6 +417,20 @@ impl PartialEq<OsString> for str {
     }
 }
 
+#[stable(feature = "rust1", since = "1.28.0")]
+impl<'a> PartialEq<&'a str> for OsString {
+    fn eq(&self, other: &&'a str) -> bool {
+        **self == **other
+    }
+}
+
+#[stable(feature = "rust1", since = "1.28.0")]
+impl<'a> PartialEq<OsString> for &'a str {
+    fn eq(&self, other: &OsString) -> bool {
+        **other == **self
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl Eq for OsString {}