1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use crate::;
/// Constructs a function-pointer type from its components.
///
/// Given
/// - a tuple of argument types (`Self`)
/// - a safety marker ([`Safety`](crate::safety::Safety))
/// - an abi ([`Abi`](crate::abi::Abi))
/// - an output type (`Output`)
///
/// The trait is implemented for tuples, which get turned into the parameter types of [`F`](BuildFn::F).
///
/// # Examples
///
/// ```rust
/// use fn_ptr::{BuildFn, safety, abi};
/// type F0 = <(i32,) as BuildFn>::F; // fn(i32)
/// type F1 = <() as BuildFn<safety::Unsafe, abi::Rust, u64>>::F; // unsafe fn() -> u64
/// type F2 = <(String, f32) as BuildFn<safety::Safe, abi::C, i32>>::F; // extern "C" fn(String, f32) -> i32
/// ```
/*
These blanket impls could replace a large portion of impl.rs but would lead to
additional bounds when using the traits.
impl<G: FnPtr, Args: BuildFn<G::Safety, G::Abi, G::Output>> WithArgs<Args> for G {
type F = <Args as BuildFn<G::Safety, G::Abi, G::Output>>::F;
}
impl<Output, G: FnPtr> WithOutput<Output> for G
where
G::Args: BuildFn<G::Safety, G::Abi, Output>,
{
type F = <G::Args as BuildFn<G::Safety, G::Abi, Output>>::F;
}
impl<Safety: safety::Safety, G: FnPtr> WithSafety<Safety> for G
where
G::Args: BuildFn<Safety, G::Abi, G::Output>,
{
type F = <G::Args as BuildFn<Safety, G::Abi, G::Output>>::F;
}
impl<Abi: abi::Abi, G: FnPtr> WithAbi<Abi> for G
where
G::Args: BuildFn<G::Safety, Abi, G::Output>,
{
type F = <G::Args as BuildFn<G::Safety, Abi, G::Output>>::F;
}
*/