1
0
Fork 0
forked from mirror/grapevine

Fix weird type gymnastics

This commit is contained in:
Lambda 2024-09-05 18:50:44 +00:00 committed by Charles Hall
parent 5c4062742f
commit 74589043f7
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF

View file

@ -171,8 +171,8 @@ impl Service {
/ u64::from(original_height)
};
if use_width {
if intermediate <= u64::from(::std::u32::MAX) {
(width, intermediate.try_into().unwrap_or(u32::MAX))
if let Ok(intermediate) = u32::try_from(intermediate) {
(width, intermediate)
} else {
(
(u64::from(width) * u64::from(::std::u32::MAX)
@ -182,8 +182,8 @@ impl Service {
::std::u32::MAX,
)
}
} else if intermediate <= u64::from(::std::u32::MAX) {
(intermediate.try_into().unwrap_or(u32::MAX), height)
} else if let Ok(intermediate) = u32::try_from(intermediate) {
(intermediate, height)
} else {
(
::std::u32::MAX,