Skip to content

Commit b487bda

Browse files
authored
Add an INIFNITY constant to Size. (#413)
This pull request adds the `INFINITY` constant to `Size`. ```rust const INFINITY: Size = Size::new(f64::INFINITY, f64::INFINITY); ``` I found myself writing a lot of infinite sizes manually to represent "no constraint", and thought it would be cleaner to have it as an associated constant instead. # Potential questions Is there any other constants we might want for `Size`? `INFINITY` is the only one I personally needed, but maybe there are others.
1 parent f2c153b commit b487bda

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/size.rs

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ impl Size {
2727
/// A size with zero width or height.
2828
pub const ZERO: Size = Size::new(0., 0.);
2929

30+
/// A size with width and height set to `f64::INFINITY`.
31+
pub const INFINITY: Size = Size::new(f64::INFINITY, f64::INFINITY);
32+
3033
/// Create a new `Size` with the provided `width` and `height`.
3134
#[inline]
3235
pub const fn new(width: f64, height: f64) -> Self {

0 commit comments

Comments
 (0)