Introduce helper types for accessing trait items
The ambiguous associated types error sometimes fires in cases where it shouldn't be ambiguous ([1]), which can make things clunky when working with chained associated types (e.g. `Op::FTy::Int::*` does not work). Add helper types that we can use instead of the full syntax. There aren't too many cases in-crate now but this is relevant for some open PRs. [1]: https://github.com/rust-lang/rust/issues/38078
This commit is contained in:
@@ -5,8 +5,8 @@ pub mod op;
|
||||
mod precision;
|
||||
mod test_traits;
|
||||
|
||||
pub use libm::support::{Float, Int};
|
||||
pub use op::{BaseName, Identifier, MathOp};
|
||||
pub use libm::support::{Float, Int, IntTy};
|
||||
pub use op::{BaseName, CFn, FTy, Identifier, MathOp, RustFn, RustRet};
|
||||
pub use precision::{MaybeOverride, SpecialCase, default_ulp};
|
||||
pub use test_traits::{CheckBasis, CheckCtx, CheckOutput, GenerateInput, Hex, TupleCall};
|
||||
|
||||
|
||||
@@ -70,6 +70,15 @@ pub trait MathOp {
|
||||
const ROUTINE: Self::RustFn;
|
||||
}
|
||||
|
||||
/// Access the associated `FTy` type from an op (helper to avoid ambiguous associated types).
|
||||
pub type FTy<Op> = <Op as MathOp>::FTy;
|
||||
/// Access the associated `CFn` type from an op (helper to avoid ambiguous associated types).
|
||||
pub type CFn<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;
|
||||
/// Access the associated `RustRet` type from an op (helper to avoid ambiguous associated types).
|
||||
pub type RustRet<Op> = <Op as MathOp>::RustRet;
|
||||
|
||||
macro_rules! do_thing {
|
||||
// Matcher for unary functions
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user