projects
/
rust-101.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
make the gray background go all the way to the right
[rust-101.git]
/
workspace
/
src
/
part07.rs
diff --git
a/workspace/src/part07.rs
b/workspace/src/part07.rs
index e2796b409855bedd9fdaca3d8dbc27fcaefaadd0..3ea4cc089e1679bd9e5de2a12fc34d0b85d350dc 100644
(file)
--- a/
workspace/src/part07.rs
+++ b/
workspace/src/part07.rs
@@
-11,7
+11,10
@@
pub trait Minimum {
pub fn vec_min<T: Minimum>(v: &Vec<T>) -> Option<&T> {
let mut min: Option<&T> = None;
for e in v {
pub fn vec_min<T: Minimum>(v: &Vec<T>) -> Option<&T> {
let mut min: Option<&T> = None;
for e in v {
- unimplemented!()
+ min = Some(match min {
+ None => e,
+ Some(n) => n.min(e)
+ });
}
min
}
}
min
}
@@
-58,7
+61,7
@@
fn test_min() {
// ## Formatting
// ## Formatting
-// All formating is handled by [`std::fmt`](http://doc.rust-lang.org/std/fmt/index.html). I won't explain
+// All formating is handled by [`std::fmt`](http
s
://doc.rust-lang.org/std/fmt/index.html). I won't explain
// all the details, and refer you to the documentation instead.
use std::fmt;
// all the details, and refer you to the documentation instead.
use std::fmt;