Skip to content

Commit

Permalink
Add PartialEq and PartialOrd impls for comparing String and &String
Browse files Browse the repository at this point in the history
This makes such comparisons more robust against the availability of
other impls.
  • Loading branch information
joshtriplett committed Jan 18, 2025
1 parent d972108 commit f7320e2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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))]
Expand Down

0 comments on commit f7320e2

Please sign in to comment.