mirror of
https://github.com/sunface/rust-by-practice.git
synced 2025-06-23 12:39:42 +00:00
update zh/traits.md
This commit is contained in:
@ -341,12 +341,14 @@ fn main() {
|
||||
}
|
||||
|
||||
// implement `fn sum` with trait bound in two ways
|
||||
fn sum<T: std::ops::Add<Output = T>>(x: T, y: T) -> T {
|
||||
fn sum<T>(x: T, y: T) -> T {
|
||||
x + y
|
||||
}
|
||||
```
|
||||
8. 🌟🌟
|
||||
```rust,editable
|
||||
|
||||
// FIX the errors
|
||||
struct Pair<T> {
|
||||
x: T,
|
||||
y: T,
|
||||
|
Reference in New Issue
Block a user