Skip to content

Commit

Permalink
Rename associated type helpers, add OpITy
Browse files Browse the repository at this point in the history
Change the names to make them less ambiguous. Additionally add `OpITy`
for accessing the same-sized integer of an operation's float type.
  • Loading branch information
tgross35 committed Dec 22, 2024
1 parent ebdb38b commit 80def21
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/libm-test/benches/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ macro_rules! musl_rand_benches {

#[cfg(feature = "build-musl")]
let musl_extra = MuslExtra {
musl_fn: Some(musl_math_sys::$fn_name as libm_test::CFn<Op>),
musl_fn: Some(musl_math_sys::$fn_name as libm_test::OpCFn<Op>),
skip_on_i586: $skip_on_i586
};

Expand Down
2 changes: 1 addition & 1 deletion crates/libm-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod precision;
mod test_traits;

pub use libm::support::{Float, Int, IntTy};
pub use op::{BaseName, CFn, FTy, Identifier, MathOp, RustFn, RustRet};
pub use op::{BaseName, Identifier, MathOp, OpCFn, OpFTy, OpRustFn, OpRustRet};
pub use precision::{MaybeOverride, SpecialCase, default_ulp};
pub use test_traits::{CheckBasis, CheckCtx, CheckOutput, GenerateInput, Hex, TupleCall};

Expand Down
10 changes: 6 additions & 4 deletions crates/libm-test/src/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ pub trait MathOp {
}

/// Access the associated `FTy` type from an op (helper to avoid ambiguous associated types).
pub type FTy<Op> = <Op as MathOp>::FTy;
pub type OpFTy<Op> = <Op as MathOp>::FTy;
/// Access the associated `FTy::Int` type from an op (helper to avoid ambiguous associated types).
pub type OpITy<Op> = <<Op as MathOp>::FTy as Float>::Int;
/// Access the associated `CFn` type from an op (helper to avoid ambiguous associated types).
pub type CFn<Op> = <Op as MathOp>::CFn;
pub type OpCFn<Op> = <Op as MathOp>::CFn;
/// Access the associated `RustFn` type from an op (helper to avoid ambiguous associated types).
pub type RustFn<Op> = <Op as MathOp>::RustFn;
pub type OpRustFn<Op> = <Op as MathOp>::RustFn;
/// Access the associated `RustRet` type from an op (helper to avoid ambiguous associated types).
pub type RustRet<Op> = <Op as MathOp>::RustRet;
pub type OpRustRet<Op> = <Op as MathOp>::RustRet;

macro_rules! do_thing {
// Matcher for unary functions
Expand Down

0 comments on commit 80def21

Please sign in to comment.