File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -57,14 +57,14 @@ fn main() {
57
57
val: u8,
58
58
}
59
59
60
- pick(123 , Foo { val: 7 }, Foo { val: 456 });
60
+ pick(false , Foo { val: 7 }, Foo { val: 99 });
61
61
```
62
62
63
63
- This is similar to C++ templates, but Rust partially compiles the generic
64
64
function immediately, so that function must be valid for all types matching
65
- the constraints. For example, try modifying ` pick ` to return ` even + odd ` if
66
- ` n == 0 ` . Even if only the ` pick ` instantiation with integers is used, Rust
67
- still considers it invalid. C++ would let you do this.
65
+ the constraints. For example, try modifying ` pick ` to return ` left + right ` if
66
+ ` cond ` is false . Even if only the ` pick ` instantiation with integers is used,
67
+ Rust still considers it invalid. C++ would let you do this.
68
68
69
69
- Generic code is turned into non-generic code based on the call sites. This is
70
70
a zero-cost abstraction: you get exactly the same result as if you had
You can’t perform that action at this time.
0 commit comments