Add PartialOrd and Ord to Vec

This commit is contained in:
Brendan Molloy 2021-08-04 17:40:10 +02:00
parent 186b2b55e7
commit 0d57dd28c9

View File

@ -1,4 +1,4 @@
use core::{fmt, hash, iter::FromIterator, mem::MaybeUninit, ops, ptr, slice};
use core::{cmp::Ordering, fmt, hash, iter::FromIterator, mem::MaybeUninit, ops, ptr, slice};
use hash32;
/// A fixed capacity [`Vec`](https://doc.rust-lang.org/std/vec/struct.Vec.html)
@ -764,6 +764,26 @@ where
// Implements Eq if underlying data is Eq
impl<T, const N: usize> Eq for Vec<T, N> where T: Eq {}
impl<T, const N: usize> PartialOrd for Vec<T, N>
where
T: PartialOrd,
{
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
PartialOrd::partial_cmp(&**self, &**other)
}
}
impl<T, const N: usize> Ord for Vec<T, N>
where
T: Ord,
{
#[inline]
fn cmp(&self, other: &Self) -> Ordering {
Ord::cmp(&**self, &**other)
}
}
impl<T, const N: usize> ops::Deref for Vec<T, N> {
type Target = [T];