We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Rectangle::snap
1 parent 2e7cc25 commit 3bb6b46Copy full SHA for 3bb6b46
core/src/rectangle.rs
@@ -203,12 +203,9 @@ impl Rectangle<f32> {
203
}
204
205
/// 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;
+ pub fn snap(self) -> Option<Rectangle<u32>> {
+ let width = (self.width + self.x.fract()) as u32;
+ let height = (self.height + self.y.fract()) as u32;
212
213
if width < 1 || height < 1 {
214
return None;
0 commit comments