|
42 | 42 |
|
43 | 43 | #![stable(feature = "rust1", since = "1.0.0")]
|
44 | 44 |
|
| 45 | +use core::cmp::Ordering; |
45 | 46 | use core::error::Error;
|
46 | 47 | use core::iter::FusedIterator;
|
47 | 48 | #[cfg(not(no_global_oom_handling))]
|
@@ -2530,12 +2531,49 @@ macro_rules! impl_eq {
|
2530 | 2531 |
|
2531 | 2532 | impl_eq! { String, str }
|
2532 | 2533 | impl_eq! { String, &'a str }
|
| 2534 | +impl_eq! { &String, str } |
2533 | 2535 | #[cfg(not(no_global_oom_handling))]
|
2534 | 2536 | impl_eq! { Cow<'a, str>, str }
|
2535 | 2537 | #[cfg(not(no_global_oom_handling))]
|
2536 | 2538 | impl_eq! { Cow<'a, str>, &'b str }
|
2537 | 2539 | #[cfg(not(no_global_oom_handling))]
|
2538 | 2540 | impl_eq! { Cow<'a, str>, String }
|
| 2541 | +#[cfg(not(no_global_oom_handling))] |
| 2542 | +impl_eq! { Cow<'a, str>, &String } |
| 2543 | + |
| 2544 | +macro_rules! impl_ord { |
| 2545 | + ($lhs:ty, $rhs: ty) => { |
| 2546 | + #[stable(feature = "rust1", since = "1.0.0")] |
| 2547 | + #[allow(unused_lifetimes)] |
| 2548 | + impl<'a, 'b> PartialOrd<$rhs> for $lhs { |
| 2549 | + #[inline] |
| 2550 | + fn partial_cmp(&self, other: &$rhs) -> Option<Ordering> { |
| 2551 | + PartialOrd::partial_cmp(&self[..], &other[..]) |
| 2552 | + } |
| 2553 | + } |
| 2554 | + |
| 2555 | + #[stable(feature = "rust1", since = "1.0.0")] |
| 2556 | + #[allow(unused_lifetimes)] |
| 2557 | + impl<'a, 'b> PartialOrd<$lhs> for $rhs { |
| 2558 | + #[inline] |
| 2559 | + fn partial_cmp(&self, other: &$lhs) -> Option<Ordering> { |
| 2560 | + PartialOrd::partial_cmp(&self[..], &other[..]) |
| 2561 | + } |
| 2562 | + } |
| 2563 | + }; |
| 2564 | +} |
| 2565 | + |
| 2566 | +impl_ord! { String, str } |
| 2567 | +impl_ord! { String, &'a str } |
| 2568 | +impl_ord! { &String, str } |
| 2569 | +#[cfg(not(no_global_oom_handling))] |
| 2570 | +impl_ord! { Cow<'a, str>, str } |
| 2571 | +#[cfg(not(no_global_oom_handling))] |
| 2572 | +impl_ord! { Cow<'a, str>, &'b str } |
| 2573 | +#[cfg(not(no_global_oom_handling))] |
| 2574 | +impl_ord! { Cow<'a, str>, String } |
| 2575 | +#[cfg(not(no_global_oom_handling))] |
| 2576 | +impl_ord! { Cow<'a, str>, &String } |
2539 | 2577 |
|
2540 | 2578 | #[stable(feature = "rust1", since = "1.0.0")]
|
2541 | 2579 | impl Default for String {
|
|
0 commit comments