Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Size2D area #222

Merged
merged 1 commit into from Aug 22, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Fixed Size2D area

  • Loading branch information
kvark committed Aug 21, 2017
commit 74936f7ed6836a6fc7ff9b9fed6b8fa76b0f141b
@@ -102,8 +102,8 @@ impl<T: Copy + Sub<T, Output=T>, U> Sub for TypedSize2D<T, U> {
}
}

impl<T: Copy + Clone + Mul<T, Output=U>, U> TypedSize2D<T, U> {
pub fn area(&self) -> U { self.width * self.height }
impl<T: Copy + Clone + Mul<T>, U> TypedSize2D<T, U> {
pub fn area(&self) -> T::Output { self.width * self.height }
}

impl<T, U> TypedSize2D<T, U>
@@ -291,4 +291,10 @@ mod size2d {
let p2 = Size2D::new(0.0, 0.0);
assert_eq!(p1 - p2, Size2D::new(0.0, 0.0));
}

#[test]
pub fn test_area() {
let p = Size2D::new(1.5, 2.0);
assert_eq!(p.area(), 3.0);
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.