| 1 | // Copyright 2024 the Fearless_SIMD Authors |
| 2 | // SPDX-License-Identifier: Apache-2.0 OR MIT |
| 3 | |
| 4 | //! Macros used by implementations |
| 5 | |
| 6 | #![allow( |
| 7 | unused_macros, |
| 8 | unused_imports, |
| 9 | reason = "Not all macros will be used by all implementations" |
| 10 | )] |
| 11 | |
| 12 | // Adapted from similar macro in pulp |
| 13 | macro_rules! delegate { |
| 14 | ( $prefix:path : $( |
| 15 | $(#[$attr: meta])* |
| 16 | $(unsafe $($placeholder: lifetime)?)? |
| 17 | fn $func: ident $(<$(const $generic: ident: $generic_ty: ty),* $(,)?>)?( |
| 18 | $($arg: ident: $ty: ty),* $(,)? |
| 19 | ) $(-> $ret: ty)?; |
| 20 | )*) => { |
| 21 | $( |
| 22 | #[doc=concat!("See [`", stringify!($prefix), "::", stringify!($func), "`].")] |
| 23 | $(#[$attr])* |
| 24 | #[inline(always)] |
| 25 | pub $(unsafe $($placeholder)?)? |
| 26 | fn $func $(<$(const $generic: $generic_ty),*>)?(self, $($arg: $ty),*) $(-> $ret)? { |
| 27 | unsafe { $func $(::<$($generic,)*>)?($($arg,)*) } |
| 28 | } |
| 29 | )* |
| 30 | }; |
| 31 | } |
| 32 | pub(crate) use delegate; |