]> git.lizzy.rs Git - rust.git/commitdiff
tutorial.md : correct formula in fn area()
authoreliovir <eliovir@gmail.com>
Tue, 24 Sep 2013 08:21:18 +0000 (10:21 +0200)
committereliovir <eliovir@gmail.com>
Tue, 24 Sep 2013 08:21:18 +0000 (10:21 +0200)
change formula (other solution could be using abs()).

doc/tutorial.md

index 2f9a84d984f87cd09564b1287e6807773b2a3710..2a7bea002e7a1ec460cc0f9db5cefbb1e0645db3 100644 (file)
@@ -737,7 +737,7 @@ fn area(sh: Shape) -> float {
     match sh {
         Circle { radius: radius, _ } => float::consts::pi * square(radius),
         Rectangle { top_left: top_left, bottom_right: bottom_right } => {
-            (bottom_right.x - top_left.x) * (bottom_right.y - top_left.y)
+            (bottom_right.x - top_left.x) * (top_left.y - bottom_right.y) 
         }
     }
 }