Skip to content

Commit f1f48b3

Browse files
author
Brendan Molloy
committed
Add Ord and PartialOrd to String
1 parent 0d57dd2 commit f1f48b3

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/string.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use core::{fmt, fmt::Write, hash, ops, str};
1+
use core::{cmp::Ordering, fmt, fmt::Write, hash, ops, str};
22

33
use hash32;
44

@@ -439,6 +439,20 @@ impl<const N: usize> PartialEq<String<N>> for &str {
439439

440440
impl<const N: usize> Eq for String<N> {}
441441

442+
impl<const N: usize> PartialOrd for String<N> {
443+
#[inline]
444+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
445+
PartialOrd::partial_cmp(&**self, &**other)
446+
}
447+
}
448+
449+
impl<const N: usize> Ord for String<N> {
450+
#[inline]
451+
fn cmp(&self, other: &Self) -> Ordering {
452+
Ord::cmp(&**self, &**other)
453+
}
454+
}
455+
442456
macro_rules! impl_from_num {
443457
($num:ty, $size:expr) => {
444458
impl<const N: usize> From<$num> for String<N> {

0 commit comments

Comments
 (0)