Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 6e101af

Browse files
committed
Add new trait implementations for Identifier and BaseName
These allow for more convenient printing, as well as storage in map types.
1 parent dc15fdd commit 6e101af

File tree

1 file changed

+14
-2
lines changed
  • crates/libm-test/src

1 file changed

+14
-2
lines changed

crates/libm-test/src/op.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,26 @@ mod shared {
2525

2626
/// An enum representing each possible symbol name (`sin`, `sinf`, `sinl`, etc).
2727
#[libm_macros::function_enum(BaseName)]
28-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
28+
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
2929
pub enum Identifier {}
3030

31+
impl fmt::Display for Identifier {
32+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33+
f.write_str(self.as_str())
34+
}
35+
}
36+
3137
/// The name without any type specifier, e.g. `sin` and `sinf` both become `sin`.
3238
#[libm_macros::base_name_enum]
33-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
39+
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
3440
pub enum BaseName {}
3541

42+
impl fmt::Display for BaseName {
43+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
44+
f.write_str(self.as_str())
45+
}
46+
}
47+
3648
/// Attributes ascribed to a `libm` routine including signature, type information,
3749
/// and naming.
3850
pub trait MathOp {

0 commit comments

Comments
 (0)