@@ -3,7 +3,7 @@ use crate::{
33 marker:: { self , Safe , Unsafe } ,
44} ;
55
6- /// Helper trait to change the ABI of a function pointer type while preserving arity, safety, and signature.
6+ /// Helper trait to change the ABI of a function pointer type while preserving arity, safety, signature, etc .
77pub trait WithAbi < Abi > : FnPtr
88where
99 Abi : marker:: Abi ,
1818 > + HasAbi < Abi > ;
1919}
2020
21- /// Helper trait to change the safety of a function pointer type while preserving arity, ABI, and signature.
21+ /// Helper trait to change the safety of a function pointer type while preserving arity, ABI, signature, etc .
2222pub trait WithSafety < Safety > : FnPtr
2323where
2424 Safety : marker:: Safety ,
@@ -33,14 +33,27 @@ where
3333 > + HasSafety < Safety > ;
3434}
3535
36- /// Helper trait to compute the safe version of a function pointer type while preserving arity, ABI, and signature.
36+ /// Helper trait to compute the safe version of a function pointer type while preserving arity, ABI, signature, etc .
3737pub trait AsSafe : WithSafety < Safe > { }
3838impl < F : WithSafety < Safe > > AsSafe for F { }
3939
40- /// Helper trait to compute the unsafe version of a function pointer type while preserving arity, ABI, and signature.
40+ /// Helper trait to compute the unsafe version of a function pointer type while preserving arity, ABI, signature, etc .
4141pub trait AsUnsafe : WithSafety < Unsafe > { }
4242impl < F : WithSafety < Unsafe > > AsUnsafe for F { }
4343
44+ /// Helper trait to change the return type of a function pointer type while preserving arguments, safety, signature, etc.
45+ pub trait WithOutput < T > : FnPtr {
46+ /// The function pointer type with the requested return type.
47+ type F : FnPtr <
48+ Args = Self :: Args ,
49+ Output = T ,
50+ ArityMarker = Self :: ArityMarker ,
51+ SafetyMarker = Self :: SafetyMarker ,
52+ AbiMarker = Self :: AbiMarker ,
53+ > ;
54+ }
55+
56+
4457cfg_tt:: cfg_tt! {
4558/// Helper trait that simplifies generic bounds when converting between funciton pointer types.
4659// using has_abi_cdecl instead of stdcall, fastcall, thiscall is to reduce compile times
0 commit comments