From c712c8df2e9c3680fbe7a992e6890c266c9d043d Mon Sep 17 00:00:00 2001 From: sparklelcm333 Date: Sat, 23 May 2026 19:02:32 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E7=AE=80=E5=8C=96=20method=5Fsyntax.md?= =?UTF-8?q?=20=E4=B8=AD=E9=87=8D=E5=A4=8D=E7=9A=84=20can=5Fhold=20?= =?UTF-8?q?=E8=AF=91=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原译注的修正代码与清单 5-15 中已修正的正文代码相同,为避免读者困惑,将译注精简为一句说明。 --- src/structs/method_syntax.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/structs/method_syntax.md b/src/structs/method_syntax.md index df235cc..3e26858 100644 --- a/src/structs/method_syntax.md +++ b/src/structs/method_syntax.md @@ -163,14 +163,7 @@ impl Rectangle { 当我们以清单 5-14 中的 `main` 函数运行这段代码时,我们将得到我们想要的输出。方法可以取我们于 `self` 参数后添加到签名的多个参数,而这些参数会与函数中的参数一样生效。 -> **译注**:实际上,这个 `can_hold` 的实现有错误,因为其没有考虑到矩形倒转后可以容纳的情况,改进后的 `can_hold` 如下。 -> -> ```rust -> fn can_hold(&self, other: &Rectangle) -> bool { -> (self.width > other.width && self.height > other.height) -> || (self.width > other.height && self.height > other.width) -> } -> ``` +> **译注**:实际上,英文原版的 can_hold 实现未考虑矩形旋转后仍可容纳的情况,此处已修正。 ## 关联函数