2.2.1 命名约定
命名约定 — Comprehensive Rust
1分钟内可阅读完
译文 · 基于 Comprehensive Rust
原文链接: https://google.github.io/comprehensive-rust/idiomatic/foundations-api-design/predictable-api.html
通过命名约定与实现常见 trait,让你的 API 可预测。
| |
可预测的 API 是指:用户能根据名称、类型与签名等表层细节,对 API 某部分做出合理假设。
我们将审视 Rust 中常见的命名约定——它们让用户能快速搜索符合需求的方法,并快速理解现有代码。
我们还将审视类型常实现的常见 trait,以及何时为你定义的类型实现它们。