Skip to content

Commit 64b3995

Browse files
committed
Add optional dependency on ordering crate
Add an optional dependency on the `ordering` crate and implement `ArbitraryOrd` for `Fe32` if the feature is enabled.
1 parent b9eb76f commit 64b3995

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@ alloc = []
1919
[target.'cfg(mutate)'.dev-dependencies]
2020
mutagen = { git = "https://github.com/llogiq/mutagen" }
2121

22+
[dependencies]
23+
ordered = { version = "0.2.2", optional = true}
24+
2225
[lints.rust]
2326
unexpected_cfgs = { level = "deny", check-cfg = [ 'cfg(bench)', 'cfg(kani)', 'cfg(mutate)' ] }

src/primitives/gf32.rs

+6
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ impl AsRef<u8> for Fe32 {
256256
fn as_ref(&self) -> &u8 { &self.0 }
257257
}
258258

259+
/// Field elements do not have a natural order however some users may want to order them.
260+
#[cfg(feature = "ordered")]
261+
impl ordered::ArbitraryOrd for Fe32 {
262+
fn arbitrary_cmp(&self, other: &Self) -> core::cmp::Ordering { self.0.cmp(&other.0) }
263+
}
264+
259265
impl super::Field for Fe32 {
260266
const ZERO: Self = Fe32::Q;
261267
const ONE: Self = Fe32::P;

0 commit comments

Comments
 (0)