logo
pub struct Padding {
    pub top: u16,
    pub right: u16,
    pub bottom: u16,
    pub left: u16,
}
Expand description

An amount of space to pad for each side of a box

You can leverage the From trait to build Padding conveniently:

let padding = Padding::from(20);              // 20px on all sides
let padding = Padding::from([10, 20]);        // top/bottom, left/right
let padding = Padding::from([5, 10, 15, 20]); // top, right, bottom, left

Normally, the padding method of a widget will ask for an Into<Padding>, so you can easily write:

impl Widget {
    pub fn padding(mut self, padding: impl Into<Padding>) -> Self {
        // ...
        self
    }
}

let widget = Widget::new().padding(20);              // 20px on all sides
let widget = Widget::new().padding([10, 20]);        // top/bottom, left/right
let widget = Widget::new().padding([5, 10, 15, 20]); // top, right, bottom, left

Fields

top: u16

Top padding

right: u16

Right padding

bottom: u16

Bottom padding

left: u16

Left padding

Implementations

Padding of zero

Create a Padding that is equal on all sides

Returns the total amount of vertical Padding.

Returns the total amount of horizontal Padding.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.