Use .fold for comp_min and comp_max
This commit is contained in:
parent
0772d14d59
commit
34af62601b
1 changed files with 2 additions and 2 deletions
|
@ -139,10 +139,10 @@ pub trait Vector
|
||||||
#[inline] fn dot(&self, other: &Self) -> S { self.mul_v(other).comp_add() }
|
#[inline] fn dot(&self, other: &Self) -> S { self.mul_v(other).comp_add() }
|
||||||
|
|
||||||
/// The minimum component of the vector.
|
/// The minimum component of the vector.
|
||||||
#[inline] fn comp_min(&self) -> S { self.iter().min().unwrap().clone() }
|
#[inline] fn comp_min(&self) -> S { self.fold(|a, b| a.min(b)) }
|
||||||
|
|
||||||
/// The maximum component of the vector.
|
/// The maximum component of the vector.
|
||||||
#[inline] fn comp_max(&self) -> S { self.iter().max().unwrap().clone() }
|
#[inline] fn comp_max(&self) -> S { self.fold(|a, b| a.max(b)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline] fn dot<S: Primitive, Slice, V: Vector<S, Slice>>(a: V, b: V) -> S { a.dot(&b) }
|
#[inline] fn dot<S: Primitive, Slice, V: Vector<S, Slice>>(a: V, b: V) -> S { a.dot(&b) }
|
||||||
|
|
Loading…
Reference in a new issue