layout: Use saturating_add() in several places
Browse files at this commit097c415036ed63c0736a6434ab9be25fbac042e1Parent: 2d16c041 changed file +9 -6
- src/layout/tile.rs +9 -6
src/layout/tile.rsmodified+9 -6
| @@ -130,7 +130,8 @@ impl<W: LayoutElement> Tile<W> { | |||
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | if let Some(width) = self.effective_border_width() { | 132 | if let Some(width) = self.effective_border_width() { |
| 133 | - size += (width * 2, width * 2).into(); | 133 | + size.w = size.w.saturating_add(width * 2); |
| 134 | + size.h = size.h.saturating_add(width * 2); | ||
| 134 | } | 135 | } |
| 135 | 136 | ||
| 136 | size | 137 | size |
| @@ -172,7 +173,7 @@ impl<W: LayoutElement> Tile<W> { | |||
| 172 | if self.border.is_off() { | 173 | if self.border.is_off() { |
| 173 | size | 174 | size |
| 174 | } else { | 175 | } else { |
| 175 | - size + self.border.width() * 2 | 176 | + size.saturating_add(self.border.width() * 2) |
| 176 | } | 177 | } |
| 177 | } | 178 | } |
| 178 | 179 | ||
| @@ -180,7 +181,7 @@ impl<W: LayoutElement> Tile<W> { | |||
| 180 | if self.border.is_off() { | 181 | if self.border.is_off() { |
| 181 | size | 182 | size |
| 182 | } else { | 183 | } else { |
| 183 | - size + self.border.width() * 2 | 184 | + size.saturating_add(self.border.width() * 2) |
| 184 | } | 185 | } |
| 185 | } | 186 | } |
| 186 | 187 | ||
| @@ -204,7 +205,9 @@ impl<W: LayoutElement> Tile<W> { | |||
| 204 | if let Some(width) = self.effective_border_width() { | 205 | if let Some(width) = self.effective_border_width() { |
| 205 | size.w = max(1, size.w); | 206 | size.w = max(1, size.w); |
| 206 | size.h = max(1, size.h); | 207 | size.h = max(1, size.h); |
| 207 | - size += (width * 2, width * 2).into(); | 208 | + |
| 209 | + size.w = size.w.saturating_add(width * 2); | ||
| 210 | + size.h = size.h.saturating_add(width * 2); | ||
| 208 | } | 211 | } |
| 209 | 212 | ||
| 210 | size | 213 | size |
| @@ -215,10 +218,10 @@ impl<W: LayoutElement> Tile<W> { | |||
| 215 | 218 | ||
| 216 | if let Some(width) = self.effective_border_width() { | 219 | if let Some(width) = self.effective_border_width() { |
| 217 | if size.w > 0 { | 220 | if size.w > 0 { |
| 218 | - size.w += width * 2; | 221 | + size.w = size.w.saturating_add(width * 2); |
| 219 | } | 222 | } |
| 220 | if size.h > 0 { | 223 | if size.h > 0 { |
| 221 | - size.h += width * 2; | 224 | + size.h = size.h.saturating_add(width * 2); |
| 222 | } | 225 | } |
| 223 | } | 226 | } |
| 224 | 227 | ||