Use UiRect::all to build the UiRect constants (#18372)

# Objective

Use the const `all` fn to create the UiRect consts instead of setting
the fields individually.
This commit is contained in:
ickshonpe 2025-03-17 21:51:11 +00:00 committed by GitHub
parent e6a6c9fb4c
commit df1aa39ae4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -335,26 +335,9 @@ pub struct UiRect {
}
impl UiRect {
pub const DEFAULT: Self = Self {
left: Val::ZERO,
right: Val::ZERO,
top: Val::ZERO,
bottom: Val::ZERO,
};
pub const ZERO: Self = Self {
left: Val::ZERO,
right: Val::ZERO,
top: Val::ZERO,
bottom: Val::ZERO,
};
pub const AUTO: Self = Self {
left: Val::Auto,
right: Val::Auto,
top: Val::Auto,
bottom: Val::Auto,
};
pub const DEFAULT: Self = Self::all(Val::ZERO);
pub const ZERO: Self = Self::all(Val::ZERO);
pub const AUTO: Self = Self::all(Val::Auto);
/// Creates a new [`UiRect`] from the values specified.
///
@ -826,15 +809,7 @@ mod tests {
#[test]
fn uirect_default_equals_const_default() {
assert_eq!(
UiRect::default(),
UiRect {
left: Val::ZERO,
right: Val::ZERO,
top: Val::ZERO,
bottom: Val::ZERO
}
);
assert_eq!(UiRect::default(), UiRect::all(Val::ZERO));
assert_eq!(UiRect::default(), UiRect::DEFAULT);
}