fearless_simd/
impl_macros.rs

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
13macro_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            #[allow(clippy::not_unsafe_ptr_arg_deref, reason = "TODO: https://github.com/linebender/fearless_simd/issues/40")]
23            #[doc=concat!("See [`", stringify!($prefix), "::", stringify!($func), "`].")]
24            $(#[$attr])*
25            #[inline(always)]
26            pub $(unsafe $($placeholder)?)?
27            fn $func $(<$(const $generic: $generic_ty),*>)?(self, $($arg: $ty),*) $(-> $ret)? {
28                unsafe { $func $(::<$($generic,)*>)?($($arg,)*) }
29            }
30        )*
31    };
32}
33pub(crate) use delegate;