fn-ptr 0.9.1

A utility crate for introspecting and rewriting function pointer types at compile time.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use fn_ptr::with_output;

use static_assertions::assert_type_eq_all;

#[test]
fn with_output_changes_return_type_preserving_safety_and_abi() {
    type F = unsafe extern "C" fn(i32) -> f64;
    assert_type_eq_all!(with_output!(u64, F), unsafe extern "C" fn(i32) -> u64);
}

#[test]
fn with_output_on_rust_fn_pointer() {
    type F = fn(i32) -> i32;
    assert_type_eq_all!(with_output!((), F), fn(i32) -> ());
}