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(container: &C) -> i32 where C: Contains { ... } // 使用关联类型 -fn difference(container: &C) -> i32 { ... } +fn difference(container: &C) -> i32 where + C: Contains { ... } ``` 让我们使用关联类型来重写上一小节的例子: @@ -61,7 +62,9 @@ impl Contains for Container { fn last(&self) -> i32 { self.1 } } -fn difference(container: &C) -> i32 { +fn difference(container: &C) -> i32 + where C: Contains +{ container.last() - container.first() }