diff options
author | 2021-06-01 19:45:47 +0700 | |
---|---|---|
committer | 2021-06-01 19:45:47 +0700 | |
commit | 8a3b71df8b619571ce0a972826cb5a3987b66b3d (patch) | |
tree | 3d1655b36aa8d7151c878e1879c03c8271a466a5 /core | |
parent | b94cd7a2a83d81769d31f6379539089ce68cbdcd (diff) | |
download | iced-8a3b71df8b619571ce0a972826cb5a3987b66b3d.tar.gz iced-8a3b71df8b619571ce0a972826cb5a3987b66b3d.tar.bz2 iced-8a3b71df8b619571ce0a972826cb5a3987b66b3d.zip |
Replace ignored doc-tests with additional documentation for `Padding`
Diffstat (limited to 'core')
-rw-r--r-- | core/src/padding.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/core/src/padding.rs b/core/src/padding.rs index 6eafd44d..22467d6b 100644 --- a/core/src/padding.rs +++ b/core/src/padding.rs @@ -1,4 +1,36 @@ /// An amount of space to pad for each side of a box +/// +/// You can leverage the `From` trait to build [`Padding`] conveniently: +/// +/// ``` +/// # use iced_core::Padding; +/// # +/// 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: +/// +/// ``` +/// # use iced_core::Padding; +/// # +/// # struct Widget; +/// # +/// impl Widget { +/// # pub fn new() -> Self { Self } +/// # +/// 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 +/// ``` #[derive(Debug, Hash, Copy, Clone)] pub struct Padding { /// Top padding |