1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#[derive(Debug, Clone, PartialEq)]
pub struct Size(pub f32, pub f32);
impl Size {
pub fn from_radius(radius: f32) -> Self {
Self(radius * 2.0, radius * 2.0)
}
pub fn from_height(height: f32) -> Self {
Self(f32::INFINITY, height)
}
pub fn from_width(width: f32) -> Self {
Self(width, f32::INFINITY)
}
pub fn square(dimension: f32) -> Self {
Self(dimension, dimension)
}
}
impl Default for Size {
fn default() -> Self {
Self(Default::default(), Default::default())
}
}