Skip to content

Commit 8338d70

Browse files
committed
add attribute reference to readme
1 parent 9c7acd0 commit 8338d70

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
Derive `Debug` with a custom format per field.
44

5-
# Usage
5+
# Example usage
66

7-
Here is a showcase of all possible field attributes:
7+
Here is a showcase of `custom_debug`s features:
88

99
```rust
1010
use custom_debug::Debug;
@@ -34,4 +34,22 @@ Foo {
3434
x: 42 things,
3535
z: 0xAB
3636
}
37-
```
37+
```
38+
39+
# Field attributes reference
40+
41+
Attributes within a section below are considered mutually exclusive.
42+
43+
## Skip attributes
44+
45+
| | |
46+
|-|-|
47+
| `skip` | Unconditionally skips a field. |
48+
| `skip_if = path::to::function` | Skips a field if `path::to::function(&field)` returns `true`. |
49+
50+
## Format attributes
51+
52+
| | |
53+
|-|-|
54+
| `format = "format string {}"` | Formats a field using a format string. Must contain a placeholder (`{}`) with modifiers of your choice. |
55+
| `with = path::to::formatter` | Formats a field using `path::to::formatter`. The required signature is `fn(&T, &mut std::fmt::Formatter) -> std::fmt::Result` where `T` is a type compatible with the field's type (i.e. the function can be generic and coercions apply). |

0 commit comments

Comments
 (0)