diff --git a/crates/bevy_ui/src/geometry.rs b/crates/bevy_ui/src/geometry.rs index 76168c98e0..fd90c711c9 100644 --- a/crates/bevy_ui/src/geometry.rs +++ b/crates/bevy_ui/src/geometry.rs @@ -358,6 +358,17 @@ impl Size { } /// Creates a new [`Size`] where both sides take the given value. + /// + /// # Example + /// + /// ``` + /// # use bevy_ui::{Size, Val}; + /// # + /// let size = Size::all(Val::Px(10.)); + /// + /// assert_eq!(size.width, Val::Px(10.0)); + /// assert_eq!(size.height, Val::Px(10.0)); + /// ``` pub const fn all(value: Val) -> Self { Self { width: value, @@ -365,7 +376,18 @@ impl Size { } } - /// Creates a new [`Size`] where `width` takes the given value. + /// Creates a new [`Size`] where `width` takes the given value and its `height` is `Val::Auto`. + /// + /// # Example + /// + /// ``` + /// # use bevy_ui::{Size, Val}; + /// # + /// let size = Size::width(Val::Px(10.)); + /// + /// assert_eq!(size.width, Val::Px(10.0)); + /// assert_eq!(size.height, Val::Auto); + /// ``` pub const fn width(width: Val) -> Self { Self { width, @@ -373,7 +395,18 @@ impl Size { } } - /// Creates a new [`Size`] where `height` takes the given value. + /// Creates a new [`Size`] where `height` takes the given value and its `width` is `Val::Auto`. + /// + /// # Example + /// + /// ``` + /// # use bevy_ui::{Size, Val}; + /// # + /// let size = Size::height(Val::Px(10.)); + /// + /// assert_eq!(size.width, Val::Auto); + /// assert_eq!(size.height, Val::Px(10.)); + /// ``` pub const fn height(height: Val) -> Self { Self { width: Val::Auto,