Skip to content

Commit 3bb6b46

Browse files
authored
Simplify Rectangle::snap
1 parent 2e7cc25 commit 3bb6b46

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

core/src/rectangle.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,9 @@ impl Rectangle<f32> {
203203
}
204204

205205
/// Snaps the [`Rectangle`] to __unsigned__ integer coordinates.
206-
pub fn snap(mut self) -> Option<Rectangle<u32>> {
207-
self.width += self.x.fract();
208-
self.height += self.y.fract();
209-
210-
let width = self.width as u32;
211-
let height = self.height as u32;
206+
pub fn snap(self) -> Option<Rectangle<u32>> {
207+
let width = (self.width + self.x.fract()) as u32;
208+
let height = (self.height + self.y.fract()) as u32;
212209

213210
if width < 1 || height < 1 {
214211
return None;

0 commit comments

Comments
 (0)