Skip to content

Commit 417fe03

Browse files
committed
Guideline about word order
1 parent 2fb6161 commit 417fe03

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/checklist.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [ ] Ownership suffixes use `_mut` and `_ref` ([C-OWN-SUFFIX])
1111
- [ ] Single-element containers implement appropriate getters ([C-GETTERS])
1212
- [ ] Feature names are free of placeholder words ([C-FEATURE])
13+
- [ ] Names use a consistent word order ([C-WORD-ORDER])
1314
- **Interoperability** *(crate interacts nicely with other library functionality)*
1415
- [ ] Types eagerly implement common traits ([C-COMMON-TRAITS])
1516
- `Copy`, `Clone`, `Eq`, `PartialEq`, `Ord`, `PartialOrd`, `Hash`, `Debug`,
@@ -80,6 +81,7 @@
8081
[C-OWN-SUFFIX]: naming.html#c-own-suffix
8182
[C-GETTERS]: naming.html#c-getters
8283
[C-FEATURE]: naming.html#c-feature
84+
[C-WORD-ORDER]: naming.html#c-word-order
8385

8486
[C-COMMON-TRAITS]: interoperability.html#c-common-traits
8587
[C-CONV-TRAITS]: interoperability.html#c-conv-traits

src/naming.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,3 +303,25 @@ we like for explicit features to behave the same way.
303303

304304
As a related note, Cargo requires that features are additive so a feature named
305305
negatively like `no-abc` is practically never correct.
306+
307+
308+
<a id="c-word-order"></a>
309+
## Names use a consistent word order (C-WORD-ORDER)
310+
311+
Here are some error types from the standard library:
312+
313+
- [`JoinPathsError`](https://doc.rust-lang.org/std/env/struct.JoinPathsError.html)
314+
- [`ParseBoolError`](https://doc.rust-lang.org/std/str/struct.ParseBoolError.html)
315+
- [`ParseCharError`](https://doc.rust-lang.org/std/char/struct.ParseCharError.html)
316+
- [`ParseFloatError`](https://doc.rust-lang.org/std/num/struct.ParseFloatError.html)
317+
- [`ParseIntError`](https://doc.rust-lang.org/std/num/struct.ParseIntError.html)
318+
- [`RecvTimeoutError`](https://doc.rust-lang.org/std/sync/mpsc/enum.RecvTimeoutError.html)
319+
- [`StripPrefixError`](https://doc.rust-lang.org/std/path/struct.StripPrefixError.html)
320+
321+
All of these use verb-object-error word order. If we were adding an error to
322+
represent an address failing to parse, for consistency we would want to name it
323+
in verb-object-error order like `ParseAddrError` rather than `AddrParseError`.
324+
325+
The particular choice of word order is not important, but pay attention to
326+
consistency within the crate and consistency with similar functionality in the
327+
standard library.

0 commit comments

Comments
 (0)