You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# P.NAM.01 The naming convention for identifiers in the same crate should use a uniform word order
2
+
3
+
**[Description]**
4
+
5
+
The particular choice of word order is not important, but pay attention to consistency within the crate and consistency with similar functionality in the standard library.
6
+
7
+
> For example:
8
+
>
9
+
> If the naming of types in crate were in **verb-object-error** word order, we need to follow the same order when we adding new types.
10
+
11
+
Here are some error types from the standard library:
All of these use verb-object-error word order. If we were adding an error to represent an address failing to parse, for consistency we would want to name it in verb-object-error order like `ParseAddrError` rather than `AddrParseError`.
22
+
23
+
> Note: The `AddrParseError` of module `net` in the standard library is an exception. Most of the error types from the standard library follow the verb-object-error word order.
24
+
25
+
**[Bad Case]**
26
+
27
+
```rust
28
+
// Bad:Not the "verb-object-error" order, should be `ParseAddrError`
29
+
structAddrParseError {}
30
+
```
31
+
32
+
**[Good Case]**
33
+
34
+
```rust
35
+
// Good: The order is the same as the standard library
0 commit comments