projects
/
rust-101.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
cfb905d
)
fix inconsistencies in part02
test
author
Ralf Jung
<post@ralfj.de>
Wed, 23 Jan 2019 20:40:24 +0000
(21:40 +0100)
committer
Ralf Jung
<post@ralfj.de>
Wed, 23 Jan 2019 20:40:24 +0000
(21:40 +0100)
src/part02.rs
patch
|
blob
|
history
diff --git
a/src/part02.rs
b/src/part02.rs
index a97c3673114ae1662cf7e744d422e735b7992a1e..a24a9d0c3c992b1c858ab240cbe6b820ce4b087d 100644
(file)
--- a/
src/part02.rs
+++ b/
src/part02.rs
@@
-77,7
+77,7
@@
pub trait Minimum : Copy {
//@ Next, we write `vec_min` as a generic function over a type `T` that we demand to satisfy the `Minimum` trait.
//@ This requirement is called a *trait bound*.
//@ The only difference to the version from the previous part is that we call `e.min(n)` instead
//@ Next, we write `vec_min` as a generic function over a type `T` that we demand to satisfy the `Minimum` trait.
//@ This requirement is called a *trait bound*.
//@ The only difference to the version from the previous part is that we call `e.min(n)` instead
-//@ of `
std::cmp::min(n, e)`. Rust automatically figures out that `n
` is of type `T`, which implements
+//@ of `
min_i32(n, e)`. Rust automatically figures out that `e
` is of type `T`, which implements
//@ the `Minimum` trait, and hence we can call that function.
//@
//@ There is a crucial difference to templates in C++: We actually have to declare which traits
//@ the `Minimum` trait, and hence we can call that function.
//@
//@ There is a crucial difference to templates in C++: We actually have to declare which traits