mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Add XY::sum and XY::product
This commit is contained in:
parent
d6f5c0e0fa
commit
a9cbcad4d4
14
src/vec.rs
14
src/vec.rs
@ -269,6 +269,20 @@ impl<T: Ord + Add<Output = T> + Clone> XY<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: Add> XY<T> {
|
||||||
|
/// Returns `self.x + self.y`.
|
||||||
|
pub fn sum(self) -> T::Output {
|
||||||
|
self.fold(std::ops::Add::add)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Mul> XY<T> {
|
||||||
|
/// Returns `self.x * self.y`
|
||||||
|
pub fn product(self) -> T::Output {
|
||||||
|
self.fold(std::ops::Mul::mul)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: Zero + Clone> XY<T> {
|
impl<T: Zero + Clone> XY<T> {
|
||||||
/// Returns a vector with the X component of self, and y=0.
|
/// Returns a vector with the X component of self, and y=0.
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user