Add docs in Span::masked method

pull/648/head
sudipghimire533 2 years ago committed by Sudip Ghimire
parent ec0d8bbe25
commit 6364a098f0

@ -110,6 +110,17 @@ impl<'a> Span<'a> {
} }
} }
/// Create a span with given style and mask
///
/// # Examples
///
/// ```rust
/// # use tui::text::Span;
/// # use tui::style::{Color, Modifier, Style};
/// let style = Style::default();
/// Span::masked("Cool password", style, 'x');
/// Span::masked(String::from("You cannot see this"), style, '*');
/// ```
pub fn masked<T>(content: T, style: Style, mask: char) -> Span<'a> pub fn masked<T>(content: T, style: Style, mask: char) -> Span<'a>
where where
T: Into<Cow<'a, str>>, T: Into<Cow<'a, str>>,
@ -151,6 +162,7 @@ impl<'a> Span<'a> {
/// add_modifier: Modifier::empty(), /// add_modifier: Modifier::empty(),
/// sub_modifier: Modifier::empty(), /// sub_modifier: Modifier::empty(),
/// }, /// },
/// mask: None,
/// }, /// },
/// StyledGrapheme { /// StyledGrapheme {
/// symbol: "e", /// symbol: "e",
@ -160,6 +172,7 @@ impl<'a> Span<'a> {
/// add_modifier: Modifier::empty(), /// add_modifier: Modifier::empty(),
/// sub_modifier: Modifier::empty(), /// sub_modifier: Modifier::empty(),
/// }, /// },
/// mask: None,
/// }, /// },
/// StyledGrapheme { /// StyledGrapheme {
/// symbol: "x", /// symbol: "x",
@ -169,6 +182,7 @@ impl<'a> Span<'a> {
/// add_modifier: Modifier::empty(), /// add_modifier: Modifier::empty(),
/// sub_modifier: Modifier::empty(), /// sub_modifier: Modifier::empty(),
/// }, /// },
/// mask: None,
/// }, /// },
/// StyledGrapheme { /// StyledGrapheme {
/// symbol: "t", /// symbol: "t",
@ -178,6 +192,7 @@ impl<'a> Span<'a> {
/// add_modifier: Modifier::empty(), /// add_modifier: Modifier::empty(),
/// sub_modifier: Modifier::empty(), /// sub_modifier: Modifier::empty(),
/// }, /// },
/// mask: None,
/// }, /// },
/// ], /// ],
/// styled_graphemes.collect::<Vec<StyledGrapheme>>() /// styled_graphemes.collect::<Vec<StyledGrapheme>>()

Loading…
Cancel
Save