From 4d73035a4ea9b4302a7b2569f884898bef612c18 Mon Sep 17 00:00:00 2001 From: expectocode Date: Tue, 31 Dec 2019 00:54:00 +0000 Subject: [PATCH] Call one Rectangle constructor from the others --- src/geometry.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/geometry.rs b/src/geometry.rs index 3afe576..5c645da 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -92,19 +92,11 @@ impl Rectangle { let width = (corner_a.x() as i64 - corner_b.x() as i64).abs() as u32; let height = (corner_a.y() as i64 - corner_b.y() as i64).abs() as u32; - Rectangle { - top_left: Point::new(left, top), - width, - height, - } + Rectangle::from_corner_width_height(Point::new(left, top), width, height) } fn at_origin_with_size(width: u32, height: u32) -> Rectangle { - Rectangle { - top_left: Point::origin(), - width, - height, - } + Rectangle::from_corner_width_height(Point::origin(), width, height) } fn width(&self) -> u32 {