From 8c354f6491bc7eb42727be8ce01032a1c4a96e4d Mon Sep 17 00:00:00 2001
From: Amesy <amesy1110@gmail.com>
Date: Sat, 7 Jan 2023 17:00:42 +0800
Subject: [PATCH] Update types.md
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

更新为where子句,代码看起来更清晰。
---
 src/generics/assoc_items/types.md | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/generics/assoc_items/types.md b/src/generics/assoc_items/types.md
index 91514099..a0031aa0 100644
--- a/src/generics/assoc_items/types.md
+++ b/src/generics/assoc_items/types.md
@@ -22,7 +22,8 @@ fn difference<A, B, C>(container: &C) -> i32 where
     C: Contains<A, B> { ... }
 
 // 使用关联类型
-fn difference<C: Contains>(container: &C) -> i32 { ... }
+fn difference<C>(container: &C) -> i32 where 
+    C: Contains { ... }
 ```
 
 让我们使用关联类型来重写上一小节的例子:
@@ -61,7 +62,9 @@ impl Contains for Container {
     fn last(&self) -> i32 { self.1 }
 }
 
-fn difference<C: Contains>(container: &C) -> i32 {
+fn difference<C>(container: &C) -> i32 
+    where C: Contains 
+{
     container.last() - container.first()
 }