From f7320e2afe5e25e90b4fdae172b02408628125a0 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sat, 18 Jan 2025 14:10:03 +0200 Subject: [PATCH] Add PartialEq and PartialOrd impls for comparing `String` and `&String` This makes such comparisons more robust against the availability of other impls. --- library/alloc/src/string.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 093a9ea81eeda..f38e4a50044a7 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -2531,6 +2531,7 @@ macro_rules! impl_eq { impl_eq! { String, str } impl_eq! { String, &'a str } +impl_eq! { String, &String } impl_eq! { &String, str } #[cfg(not(no_global_oom_handling))] impl_eq! { Cow<'a, str>, str } @@ -2566,6 +2567,7 @@ macro_rules! impl_ord { impl_ord! { String, str } impl_ord! { String, &'a str } impl_ord! { &String, str } +impl_ord! { String, &String } #[cfg(not(no_global_oom_handling))] impl_ord! { Cow<'a, str>, str } #[cfg(not(no_global_oom_handling))]