#[repr(C)]pub struct Style {
pub width: Length,
pub height: Length,
pub padding: Edges<i8>,
pub bg: Color,
pub border_color: Color,
pub gap: i8,
pub rounded: u8,
pub border_width: u8,
pub flex_flags: u8,
}Expand description
紧凑位域样式结构体(严格 24 字节)。
Fields§
§width: Length宽度策略(4 Bytes)。
height: Length高度策略(4 Bytes)。
padding: Edges<i8>四周内边距(4 Bytes)。
bg: Color背景填充色(4 Bytes)。
border_color: Color边框颜色(4 Bytes)。
gap: i8子节点间距(1 Byte)。
rounded: u8圆角半径 0..=127px(1 Byte)。
border_width: u8边框宽度(1 Byte)。
flex_flags: u8位域:flex_dir(1b) | justify(3b) | items_align(2b) | flex_grow(2b)(1 Byte)。
Implementations§
Source§impl Style
impl Style
Sourcepub fn set_justify(&mut self, justify: Justify)
pub fn set_justify(&mut self, justify: Justify)
设置主轴对齐方式。
Sourcepub fn set_justify_center(&mut self)
pub fn set_justify_center(&mut self)
设置主轴居中对齐。
Sourcepub fn set_justify_between(&mut self)
pub fn set_justify_between(&mut self)
设置主轴两端对齐。
Sourcepub fn set_items_align(&mut self, align: AlignItems)
pub fn set_items_align(&mut self, align: AlignItems)
设置交叉轴对齐方式。
Sourcepub fn set_items_center(&mut self)
pub fn set_items_center(&mut self)
设置交叉轴居中对齐。
Sourcepub const fn items_align(&self) -> AlignItems
pub const fn items_align(&self) -> AlignItems
读取交叉轴对齐方式。
Sourcepub const fn rounded_radius(&self) -> u8
pub const fn rounded_radius(&self) -> u8
读取圆角半径(0..=127px,剥离最高位 flex_wrap 标志)。
Sourcepub fn set_rounded(&mut self, radius: u8)
pub fn set_rounded(&mut self, radius: u8)
设置圆角半径(0..=127px,保留最高位 flex_wrap 标志)。
Sourcepub fn set_flex_wrap(&mut self, wrap: bool)
pub fn set_flex_wrap(&mut self, wrap: bool)
设置多行自动折行(flex_wrap)。
Sourcepub fn set_border_px(&mut self, width: u8)
pub fn set_border_px(&mut self, width: u8)
设置边框宽度(0..=15px)。
Sourcepub fn set_margin_px(&mut self, px: i8)
pub fn set_margin_px(&mut self, px: i8)
设置四边统一外边距(0..=15px)。
Trait Implementations§
impl Copy for Style
impl Eq for Style
impl StructuralPartialEq for Style
Auto Trait Implementations§
impl Forget for Style
impl Freeze for Style
impl Move for Style
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnsafeUnpin for Style
impl UnwindSafe for Style
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> FluentBuilder for T
impl<T> FluentBuilder for T
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
当
condition 为 true 时执行闭包修饰自身,否则原样返回。Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Self
fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self
根据
condition 在两个修饰分支之间二选一。Source§fn when_some<O>(
self,
option: Option<O>,
then: impl FnOnce(Self, O) -> Self,
) -> Self
fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self
当
option 为 Some(value) 时执行闭包修饰自身,否则原样返回。