调整措辞,以便于理解。

pull/872/head
须语 6 days ago
parent b3685f5f4a
commit 4ae2b80d39

@ -98,7 +98,7 @@ trait Add<Rhs=Self> {
### 在同名方法之间消歧义
Rust 既不能避免一个 trait 与另一个 trait 拥有相同名称的方法,也不能阻止为同一类型同时实现这两个 trait。同时可以直接在类型上实现一个与 trait 方法同名的方法。
Rust 既不能避免一个 trait 与另一个 trait 拥有相同名称的方法,也不能阻止为同一类型同时实现这两个 trait。同时可以直接在类型上实现一个与 trait 方法同名的方法。
当调用这些同名方法时,需要告诉 Rust 我们想要使用哪一个。考虑一下示例 20-17 中的代码,这里我们定义了两个 trait`Pilot` 和 `Wizard`,它们都拥有名为 `fly` 的方法。接着在一个本身已经实现了名为 `fly` 方法的类型 `Human` 上实现这两个 trait。每一个 `fly` 方法都进行了不同的操作:

Loading…
Cancel
Save