Skip to content

Commit d212491

Browse files
authored
Implement From<Val> for UiRect (#20312)
# Objective Instead of: ```rust Node { margin: UiRect::all(Val::Px(20.)), border: UiRect::all(Val::Px(5.)), padding: UiRect::all(Val::Px(10.)), ..default() } ``` allow: ```rust Node { margin: Val::Px(20.).into(), border: Val::Px(5.).into(), padding: Val::Px(10.).into(), ..default() } ``` Which matches how single edge values are interpreted in CSS. ## Solution Implement `From<Val>` for `UiRect`.
1 parent 1df54ed commit d212491

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

crates/bevy_ui/src/geometry.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,12 @@ impl Default for UiRect {
687687
}
688688
}
689689

690+
impl From<Val> for UiRect {
691+
fn from(value: Val) -> Self {
692+
UiRect::all(value)
693+
}
694+
}
695+
690696
#[derive(Debug, Clone, Copy, PartialEq, Reflect)]
691697
#[reflect(Default, Debug, PartialEq)]
692698
#[cfg_attr(

0 commit comments

Comments
 (0)