ff: Add Ord bound to PrimeField

This commit is contained in:
Jack Grigg
2020-04-23 16:30:36 +12:00
parent 1a40cfd39c
commit 1fe3e3784c
4 changed files with 36 additions and 16 deletions

View File

@@ -272,6 +272,20 @@ impl ConstantTimeEq for Fs {
}
}
impl Ord for Fs {
#[inline(always)]
fn cmp(&self, other: &Fs) -> ::std::cmp::Ordering {
self.into_repr().cmp(&other.into_repr())
}
}
impl PartialOrd for Fs {
#[inline(always)]
fn partial_cmp(&self, other: &Fs) -> Option<::std::cmp::Ordering> {
Some(self.cmp(other))
}
}
impl ::std::fmt::Display for Fs {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(f, "Fs({})", self.into_repr())