Show rule doc example in multiple places
This commit is contained in:
parent
b778d5cd56
commit
24fcc57873
2 changed files with 67 additions and 3 deletions
|
|
@ -1149,7 +1149,22 @@ pub fn vertical_space() -> Space {
|
||||||
|
|
||||||
/// Creates a horizontal [`Rule`] with the given height.
|
/// Creates a horizontal [`Rule`] with the given height.
|
||||||
///
|
///
|
||||||
/// [`Rule`]: crate::Rule
|
/// # Example
|
||||||
|
/// ```no_run
|
||||||
|
/// # mod iced { pub mod widget { pub use iced_widget::*; } }
|
||||||
|
/// # pub type State = ();
|
||||||
|
/// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
|
||||||
|
/// use iced::widget::horizontal_rule;
|
||||||
|
///
|
||||||
|
/// #[derive(Clone)]
|
||||||
|
/// enum Message {
|
||||||
|
/// // ...,
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// fn view(state: &State) -> Element<'_, Message> {
|
||||||
|
/// horizontal_rule(2).into()
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
pub fn horizontal_rule<'a, Theme>(height: impl Into<Pixels>) -> Rule<'a, Theme>
|
pub fn horizontal_rule<'a, Theme>(height: impl Into<Pixels>) -> Rule<'a, Theme>
|
||||||
where
|
where
|
||||||
Theme: rule::Catalog + 'a,
|
Theme: rule::Catalog + 'a,
|
||||||
|
|
@ -1159,7 +1174,22 @@ where
|
||||||
|
|
||||||
/// Creates a vertical [`Rule`] with the given width.
|
/// Creates a vertical [`Rule`] with the given width.
|
||||||
///
|
///
|
||||||
/// [`Rule`]: crate::Rule
|
/// # Example
|
||||||
|
/// ```no_run
|
||||||
|
/// # mod iced { pub mod widget { pub use iced_widget::*; } }
|
||||||
|
/// # pub type State = ();
|
||||||
|
/// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
|
||||||
|
/// use iced::widget::vertical_rule;
|
||||||
|
///
|
||||||
|
/// #[derive(Clone)]
|
||||||
|
/// enum Message {
|
||||||
|
/// // ...,
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// fn view(state: &State) -> Element<'_, Message> {
|
||||||
|
/// vertical_rule(2).into()
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
pub fn vertical_rule<'a, Theme>(width: impl Into<Pixels>) -> Rule<'a, Theme>
|
pub fn vertical_rule<'a, Theme>(width: impl Into<Pixels>) -> Rule<'a, Theme>
|
||||||
where
|
where
|
||||||
Theme: rule::Catalog + 'a,
|
Theme: rule::Catalog + 'a,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,21 @@
|
||||||
//! Display a horizontal or vertical rule for dividing content.
|
//! Rules divide space horizontally or vertically.
|
||||||
|
//!
|
||||||
|
//! # Example
|
||||||
|
//! ```no_run
|
||||||
|
//! # mod iced { pub mod widget { pub use iced_widget::*; } }
|
||||||
|
//! # pub type State = ();
|
||||||
|
//! # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
|
||||||
|
//! use iced::widget::horizontal_rule;
|
||||||
|
//!
|
||||||
|
//! #[derive(Clone)]
|
||||||
|
//! enum Message {
|
||||||
|
//! // ...,
|
||||||
|
//! }
|
||||||
|
//!
|
||||||
|
//! fn view(state: &State) -> Element<'_, Message> {
|
||||||
|
//! horizontal_rule(2).into()
|
||||||
|
//! }
|
||||||
|
//! ```
|
||||||
use crate::core;
|
use crate::core;
|
||||||
use crate::core::border;
|
use crate::core::border;
|
||||||
use crate::core::layout;
|
use crate::core::layout;
|
||||||
|
|
@ -10,6 +27,23 @@ use crate::core::{
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Display a horizontal or vertical rule for dividing content.
|
/// Display a horizontal or vertical rule for dividing content.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
/// ```no_run
|
||||||
|
/// # mod iced { pub mod widget { pub use iced_widget::*; } }
|
||||||
|
/// # pub type State = ();
|
||||||
|
/// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
|
||||||
|
/// use iced::widget::horizontal_rule;
|
||||||
|
///
|
||||||
|
/// #[derive(Clone)]
|
||||||
|
/// enum Message {
|
||||||
|
/// // ...,
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// fn view(state: &State) -> Element<'_, Message> {
|
||||||
|
/// horizontal_rule(2).into()
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct Rule<'a, Theme = crate::Theme>
|
pub struct Rule<'a, Theme = crate::Theme>
|
||||||
where
|
where
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue