Skip to content

Commit 8989284

Browse files
committed
Phrase unit error guideline as a checklist item
1 parent f4dd542 commit 8989284

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

README.md

+12-6
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Guidelines use active voice.
6767
- [ ] Crate has a `"serde"` cfg option that enables Serde ([C-SERDE-CFG])
6868
- [ ] Types are `Send` and `Sync` where possible ([C-SEND-SYNC])
6969
- [ ] Error types are `Send` and `Sync` ([C-SEND-SYNC-ERR])
70-
- [ ] Do not use `()` as an error type ([C-UNIT-IS-NOT-AN-ERROR])
70+
- [ ] Error types are meaningful, not `()` ([C-MEANINGFUL-ERR])
7171
- [ ] Binary number types provide `Hex`, `Octal`, `Binary` formatting ([C-NUM-FMT])
7272
- **Macros** *(crate presents well-behaved macros)*
7373
- [ ] Input syntax is evocative of the output ([C-EVOCATIVE])
@@ -607,10 +607,9 @@ bitwise manipulations like `|` or `&`. This is especially appropriate for
607607
bitflag types. Numeric quantity types like `struct Nanoseconds(u64)` probably do
608608
not need these.
609609

610-
611-
[C-UNIT-IS-NOT-AN-ERROR]: #c-unit-is-not-an-error
612-
<a id="c-unit-is-not-an-error"></a>
613-
## Do not use `()` as an error type ([C-UNIT-IS-NOT-AN-ERROR])
610+
[C-MEANINGFUL-ERR]: #c-meaningful-err
611+
<a id="c-meaningful-err"></a>
612+
## Error types are meaningful, not `()` ([C-MEANINGFUL-ERR])
614613

615614
When defining functions that return `Result`, and the error carries no
616615
useful additional information, do not use `()` is the error type. `()`
@@ -621,7 +620,14 @@ error handling libraries like [error-chain] expect errors to implement
621620

622621
[error-chain]: https://docs.rs/error-chain
623622

624-
Instead, define a nullary error type specific to your own crate.
623+
Instead, define a meaningful error type specific to your crate.
624+
625+
##### Examples from the standard library
626+
627+
- [`ParseBoolError`] is returned when failing to parse a bool from a string.
628+
629+
[`ParseBoolError`]: https://doc.rust-lang.org/std/str/struct.ParseBoolError.html
630+
625631

626632
<a id="macros"></a>
627633
## Macros

0 commit comments

Comments
 (0)