Call one Rectangle constructor from the others

master
expectocode 2019-12-31 00:54:00 +00:00
parent 5e028c20ae
commit 4d73035a4e
1 changed files with 2 additions and 10 deletions

View File

@ -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 {