Skip to content

Commit d64e8c7

Browse files
authored
Update README.md
1 parent b57adb7 commit d64e8c7

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![CI](https://github.com/OpenByteDev/fn-ptr/actions/workflows/ci.yml/badge.svg)](https://github.com/OpenByteDev/fn-ptr/actions/workflows/ci.yml) [![crates.io](https://img.shields.io/crates/v/fn-ptr.svg)](https://crates.io/crates/fn-ptr) [![Documentation](https://docs.rs/fn-ptr/badge.svg)](https://docs.rs/fn-ptr) [![dependency status](https://deps.rs/repo/github/openbytedev/fn-ptr/status.svg)](https://deps.rs/repo/github/openbytedev/fn-ptr) [![MIT](https://img.shields.io/crates/l/fn-ptr.svg)](https://github.com/OpenByteDev/fn-ptr/blob/master/LICENSE)
44

5-
`fn-ptr` is a small utility crate that provides a `FnPtr` trait, implemented for all function pointer types:
5+
`fn-ptr` is a small utility crate that provides a [`FnPtr`](https://docs.rs/fn-ptr/latest/fn_ptr/trait.FnPtr.html) trait, implemented for all function pointer types:
66
- `fn(T) -> U`
77
- `unsafe fn(T) -> U`
88
- `extern "C" fn(T)`
@@ -35,7 +35,7 @@ pub trait FnPtr {
3535

3636
1. Function-pointer metadata
3737

38-
Every function pointer automatically implements [`FnPtr`]. Depending on the type, it may also implement [`SafeFnPtr`], [`UnsafeFnPtr`], and [`HasAbi<Abi>`].
38+
Every function pointer automatically implements [`FnPtr`](https://docs.rs/fn-ptr/latest/fn_ptr/trait.FnPtr.html). Depending on the type, it may also implement [`SafeFnPtr`](https://docs.rs/fn-ptr/latest/fn_ptr/trait.SafeFnPtr.html), [`UnsafeFnPtr`](https://docs.rs/fn-ptr/latest/fn_ptr/trait.UnsafeFnPtr.html), and [`HasAbi<Abi>`](https://docs.rs/fn-ptr/latest/fn_ptr/trait.HasAbi.html).
3939

4040
```rust
4141
use fn_ptr::{FnPtr, Abi};
@@ -53,10 +53,11 @@ Const helper functions are also provided:
5353
const A: usize = fn_ptr::arity::<F>(); // 2
5454
const SAFE: bool = fn_ptr::is_safe::<F>(); // true
5555
const EXT: bool = fn_ptr::is_extern::<F>(); // true
56-
const ABI: Abi = fn_ptr::abi::<F>(); // Abi::C
56+
const ABI: Abi = fn_ptr::abi::<F>(); // Abi::C
5757
```
5858

5959
2. Changing ABIs at the type level
60+
6061
You can change the ABI of a function pointer type using macros:
6162
```rust
6263
use fn_ptr::{with_abi, Abi};
@@ -68,6 +69,7 @@ type H = with_abi!("C", extern "system" fn());
6869
```
6970

7071
3. Toggle function pointer safety
72+
7173
Macros are provided to make function pointers safe or unsafe:
7274
```rust
7375
use fn_ptr::{make_safe, make_unsafe};
@@ -80,7 +82,7 @@ type U2 = make_unsafe!(S2); // unsafe extern "C" fn(i32)
8082
```
8183

8284
## How it works under the hood
83-
All macros rely on type-level traits [`WithAbi`] and [`WithSafety`]. Each trait exposes an associated type representing the transformed function pointer. You can use these traits directly for const generics or explicit type transformations:
85+
All macros rely on type-level traits [`WithAbi`](https://docs.rs/fn-ptr/latest/fn_ptr/trait.WithAbi.html) and [`WithSafety`](https://docs.rs/fn-ptr/latest/fn_ptr/trait.WithSafety.html). Each trait exposes an associated type representing the transformed function pointer. You can use these traits directly for const generics or explicit type transformations:
8486

8587
```rust
8688
use fn_ptr::{FnPtr, WithAbi, WithSafety, Abi};

0 commit comments

Comments
 (0)