feat: implement From<Size> for (u16, u16) (#2223)

This commit is contained in:
0xb002f0
2025-11-22 16:52:10 -05:00
committed by GitHub
parent c7c3498025
commit b6588fd1fa

View File

@@ -60,6 +60,12 @@ impl From<(u16, u16)> for Size {
}
}
impl From<Size> for (u16, u16) {
fn from(size: Size) -> Self {
(size.width, size.height)
}
}
impl From<Rect> for Size {
fn from(rect: Rect) -> Self {
rect.as_size()
@@ -92,6 +98,14 @@ mod tests {
assert_eq!(size.height, 20);
}
#[test]
fn to_tuple() {
let size = Size::from((10, 20));
let (width, height) = size.into();
assert_eq!(size.width, width);
assert_eq!(size.height, height);
}
#[test]
fn from_rect() {
let size = Size::from(Rect::new(0, 0, 10, 20));