Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/safe-guides/code_style/naming/P.NAM.01.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
- [`RecvTimeoutError`](https://doc.rust-lang.org/std/sync/mpsc/enum.RecvTimeoutError.html)
- [`StripPrefixError`](https://doc.rust-lang.org/std/path/struct.StripPrefixError.html)

如果你想新增和标准库相似的错误类型,比如“解析地址错误”类型,为了保持词性一致,应该使用`ParseAddrError` 名称,而不是`AddrParseError`
如果你想新增和标准库相似的错误类型,比如“解析地址错误”类型,为了保持词性一致,应该使用`ParseAddrError` 名称,而不是`AddrParseError`。

> 说明:现在标准库文档中 net模块解析地址错误类型是 `AddrParseError`,其实和标准库中大部分错误类型遵循的 "动-宾-Error" 词序没有保持一致,所以它是一个特例。

**【反例】**
```rust
// 不符合:与标准库错误类型次序不一致,应该为 ParseAddrError
// 不符合:与标准库错误类型词序 "动-宾-Error" 不一致,应该为 ParseAddrError
struct AddrParseError {}
```

Expand Down
5 changes: 0 additions & 5 deletions src/safe-guides/coding_practice/traits/P.TRA.01.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,3 @@ impl FromStr for PhoneNumber {
}
```

**【Lint 检测】**

| lint name | Clippy 可检测 | Rustc 可检测 | Lint Group | 是否可定制 |
| ------------------------------------------------------------ | ------------- | ------------ | ---------- | ----- |
| - | no | yes | - | - |