@@ -67,7 +67,7 @@ Guidelines use active voice.
67
67
- [ ] Crate has a ` "serde" ` cfg option that enables Serde ([ C-SERDE-CFG] )
68
68
- [ ] Types are ` Send ` and ` Sync ` where possible ([ C-SEND-SYNC] )
69
69
- [ ] 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 ] )
71
71
- [ ] Binary number types provide ` Hex ` , ` Octal ` , ` Binary ` formatting ([ C-NUM-FMT] )
72
72
- ** Macros** * (crate presents well-behaved macros)*
73
73
- [ ] Input syntax is evocative of the output ([ C-EVOCATIVE] )
@@ -607,10 +607,9 @@ bitwise manipulations like `|` or `&`. This is especially appropriate for
607
607
bitflag types. Numeric quantity types like ` struct Nanoseconds(u64) ` probably do
608
608
not need these.
609
609
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] )
614
613
615
614
When defining functions that return ` Result ` , and the error carries no
616
615
useful additional information, do not use ` () ` is the error type. ` () `
@@ -621,7 +620,14 @@ error handling libraries like [error-chain] expect errors to implement
621
620
622
621
[ error-chain ] : https://docs.rs/error-chain
623
622
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
+
625
631
626
632
<a id =" macros " ></a >
627
633
## Macros
0 commit comments