Skip to content

Commit

Permalink
Implement Div<f64> and Mul<f64> for Insets
Browse files Browse the repository at this point in the history
  • Loading branch information
liferooter committed Oct 2, 2024
1 parent 7194487 commit f13b68e
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/insets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

//! A description of the distances between the edges of two rectangles.

use core::ops::{Add, Neg, Sub};
use core::ops::{Add, Div, Mul, Neg, Sub};

use crate::{Rect, Size};

Expand Down Expand Up @@ -279,6 +279,32 @@ impl Sub<Rect> for Insets {
}
}

impl Mul<f64> for Insets {
type Output = Insets;

fn mul(self, rhs: f64) -> Self::Output {
Self {
x0: self.x0 * rhs,
y0: self.y0 * rhs,
x1: self.x1 * rhs,
y1: self.y1 * rhs,
}
}
}

impl Div<f64> for Insets {
type Output = Insets;

fn div(self, rhs: f64) -> Self::Output {
Self {
x0: self.x0 / rhs,
y0: self.y0 / rhs,
x1: self.x1 / rhs,
y1: self.y1 / rhs,
}
}
}

impl Sub<Insets> for Rect {
type Output = Rect;

Expand Down

0 comments on commit f13b68e

Please sign in to comment.