diff --git a/Cargo.toml b/Cargo.toml index 701ae225a..8e3109eab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,5 +19,8 @@ alloc = [] [target.'cfg(mutate)'.dev-dependencies] mutagen = { git = "https://github.com/llogiq/mutagen" } +[dependencies] +ordered = { version = "0.2.2", optional = true} + [lints.rust] unexpected_cfgs = { level = "deny", check-cfg = [ 'cfg(bench)', 'cfg(kani)', 'cfg(mutate)' ] } diff --git a/src/primitives/gf32.rs b/src/primitives/gf32.rs index 511a51252..9eb23fd02 100644 --- a/src/primitives/gf32.rs +++ b/src/primitives/gf32.rs @@ -256,6 +256,12 @@ impl AsRef for Fe32 { fn as_ref(&self) -> &u8 { &self.0 } } +/// Field elements do not have a natural order however some users may want to order them. +#[cfg(feature = "ordered")] +impl ordered::ArbitraryOrd for Fe32 { + fn arbitrary_cmp(&self, other: &Self) -> core::cmp::Ordering { self.0.cmp(&other.0) } +} + impl super::Field for Fe32 { const ZERO: Self = Fe32::Q; const ONE: Self = Fe32::P;