From 02503029b83a295f1a03160472556fea491491f1 Mon Sep 17 00:00:00 2001 From: Gabriel Majeri Date: Tue, 29 May 2018 19:16:49 +0300 Subject: [PATCH] Implement PartialEq between &str and OsString Allows for example `os_string == "something"` --- src/libstd/ffi/os_str.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 0a3148029d053..1940a1da8a0af 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -417,6 +417,20 @@ impl PartialEq 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 for &'a str { + fn eq(&self, other: &OsString) -> bool { + **other == **self + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Eq for OsString {}