X-Git-Url: https://git.ralfj.de/rust-101.git/blobdiff_plain/8fcdbed310c53f621fba0401399659ed1a1ec446..45ec4d50797cdac0edb7c4653e71357fa6ab54a1:/workspace/src/part07.rs?ds=sidebyside diff --git a/workspace/src/part07.rs b/workspace/src/part07.rs index e2796b4..916cb01 100644 --- a/workspace/src/part07.rs +++ b/workspace/src/part07.rs @@ -11,7 +11,10 @@ pub trait Minimum { pub fn vec_min(v: &Vec) -> 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 } @@ -36,7 +39,7 @@ impl PartialEq for BigInt { } -// Now we can compare `BigInt`s. Rust treats `PratialEq` special in that it is wired to the operator `==`: +// Now we can compare `BigInt`s. Rust treats `PartialEq` special in that it is wired to the operator `==`: fn compare_big_ints() { let b1 = BigInt::new(13); let b2 = BigInt::new(37); @@ -58,7 +61,7 @@ fn test_min() { // ## 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`](https://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;