mirror of
https://github.com/ratatui-org/ratatui
synced 2024-11-25 22:20:31 +00:00
refactor: manually apply clippy::use_self for impl with lifetimes (#974)
This commit is contained in:
parent
660c7183c7
commit
525848ff4e
21 changed files with 175 additions and 176 deletions
|
@ -16,8 +16,8 @@ impl<'a> StyledGrapheme<'a> {
|
|||
///
|
||||
/// `style` accepts any type that is convertible to [`Style`] (e.g. [`Style`], [`Color`], or
|
||||
/// your own type that implements [`Into<Style>`]).
|
||||
pub fn new<S: Into<Style>>(symbol: &'a str, style: S) -> StyledGrapheme<'a> {
|
||||
StyledGrapheme {
|
||||
pub fn new<S: Into<Style>>(symbol: &'a str, style: S) -> Self {
|
||||
Self {
|
||||
symbol,
|
||||
style: style.into(),
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ impl<'a> StyledGrapheme<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Styled for StyledGrapheme<'a> {
|
||||
type Item = StyledGrapheme<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
|
|
@ -102,11 +102,11 @@ impl<'a> Line<'a> {
|
|||
/// Line::raw(String::from("test content"));
|
||||
/// Line::raw(Cow::from("test content"));
|
||||
/// ```
|
||||
pub fn raw<T>(content: T) -> Line<'a>
|
||||
pub fn raw<T>(content: T) -> Self
|
||||
where
|
||||
T: Into<Cow<'a, str>>,
|
||||
{
|
||||
Line {
|
||||
Self {
|
||||
spans: content
|
||||
.into()
|
||||
.lines()
|
||||
|
@ -135,12 +135,12 @@ impl<'a> Line<'a> {
|
|||
/// Line::styled(String::from("My text"), style);
|
||||
/// Line::styled(Cow::from("test content"), style);
|
||||
/// ```
|
||||
pub fn styled<T, S>(content: T, style: S) -> Line<'a>
|
||||
pub fn styled<T, S>(content: T, style: S) -> Self
|
||||
where
|
||||
T: Into<Cow<'a, str>>,
|
||||
S: Into<Style>,
|
||||
{
|
||||
Line {
|
||||
Self {
|
||||
spans: content
|
||||
.into()
|
||||
.lines()
|
||||
|
@ -496,7 +496,7 @@ impl std::fmt::Display for Line<'_> {
|
|||
}
|
||||
|
||||
impl<'a> Styled for Line<'a> {
|
||||
type Item = Line<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
|
|
@ -61,25 +61,25 @@ impl Display for Masked<'_> {
|
|||
}
|
||||
|
||||
impl<'a> From<&'a Masked<'a>> for Cow<'a, str> {
|
||||
fn from(masked: &'a Masked) -> Cow<'a, str> {
|
||||
fn from(masked: &'a Masked) -> Self {
|
||||
masked.value()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<Masked<'a>> for Cow<'a, str> {
|
||||
fn from(masked: Masked<'a>) -> Cow<'a, str> {
|
||||
fn from(masked: Masked<'a>) -> Self {
|
||||
masked.value()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a Masked<'_>> for Text<'a> {
|
||||
fn from(masked: &'a Masked) -> Text<'a> {
|
||||
fn from(masked: &'a Masked) -> Self {
|
||||
Text::raw(masked.value())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<Masked<'a>> for Text<'a> {
|
||||
fn from(masked: Masked<'a>) -> Text<'a> {
|
||||
fn from(masked: Masked<'a>) -> Self {
|
||||
Text::raw(masked.value())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,11 +107,11 @@ impl<'a> Span<'a> {
|
|||
/// Span::raw("test content");
|
||||
/// Span::raw(String::from("test content"));
|
||||
/// ```
|
||||
pub fn raw<T>(content: T) -> Span<'a>
|
||||
pub fn raw<T>(content: T) -> Self
|
||||
where
|
||||
T: Into<Cow<'a, str>>,
|
||||
{
|
||||
Span {
|
||||
Self {
|
||||
content: content.into(),
|
||||
style: Style::default(),
|
||||
}
|
||||
|
@ -133,12 +133,12 @@ impl<'a> Span<'a> {
|
|||
/// Span::styled("test content", style);
|
||||
/// Span::styled(String::from("test content"), style);
|
||||
/// ```
|
||||
pub fn styled<T, S>(content: T, style: S) -> Span<'a>
|
||||
pub fn styled<T, S>(content: T, style: S) -> Self
|
||||
where
|
||||
T: Into<Cow<'a, str>>,
|
||||
S: Into<Style>,
|
||||
{
|
||||
Span {
|
||||
Self {
|
||||
content: content.into(),
|
||||
style: style.into(),
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ where
|
|||
}
|
||||
|
||||
impl<'a> Styled for Span<'a> {
|
||||
type Item = Span<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
|
|
@ -86,7 +86,7 @@ impl<'a> Text<'a> {
|
|||
/// Text::raw("The first line\nThe second line");
|
||||
/// Text::raw(String::from("The first line\nThe second line"));
|
||||
/// ```
|
||||
pub fn raw<T>(content: T) -> Text<'a>
|
||||
pub fn raw<T>(content: T) -> Self
|
||||
where
|
||||
T: Into<Cow<'a, str>>,
|
||||
{
|
||||
|
@ -96,8 +96,7 @@ impl<'a> Text<'a> {
|
|||
Cow::Owned(s) if s.is_empty() => vec![Line::from("")],
|
||||
Cow::Owned(s) => s.lines().map(|l| Line::from(l.to_owned())).collect(),
|
||||
};
|
||||
|
||||
Text::from(lines)
|
||||
Self::from(lines)
|
||||
}
|
||||
|
||||
/// Create some text (potentially multiple lines) with a style.
|
||||
|
@ -115,12 +114,12 @@ impl<'a> Text<'a> {
|
|||
/// Text::styled("The first line\nThe second line", style);
|
||||
/// Text::styled(String::from("The first line\nThe second line"), style);
|
||||
/// ```
|
||||
pub fn styled<T, S>(content: T, style: S) -> Text<'a>
|
||||
pub fn styled<T, S>(content: T, style: S) -> Self
|
||||
where
|
||||
T: Into<Cow<'a, str>>,
|
||||
S: Into<Style>,
|
||||
{
|
||||
Text::raw(content).patch_style(style)
|
||||
Self::raw(content).patch_style(style)
|
||||
}
|
||||
|
||||
/// Returns the max width of all the lines.
|
||||
|
@ -375,26 +374,26 @@ impl<'a> IntoIterator for &'a mut Text<'a> {
|
|||
}
|
||||
|
||||
impl<'a> From<String> for Text<'a> {
|
||||
fn from(s: String) -> Text<'a> {
|
||||
Text::raw(s)
|
||||
fn from(s: String) -> Self {
|
||||
Self::raw(s)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a str> for Text<'a> {
|
||||
fn from(s: &'a str) -> Text<'a> {
|
||||
Text::raw(s)
|
||||
fn from(s: &'a str) -> Self {
|
||||
Self::raw(s)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<Cow<'a, str>> for Text<'a> {
|
||||
fn from(s: Cow<'a, str>) -> Text<'a> {
|
||||
Text::raw(s)
|
||||
fn from(s: Cow<'a, str>) -> Self {
|
||||
Self::raw(s)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<Span<'a>> for Text<'a> {
|
||||
fn from(span: Span<'a>) -> Text<'a> {
|
||||
Text {
|
||||
fn from(span: Span<'a>) -> Self {
|
||||
Self {
|
||||
lines: vec![Line::from(span)],
|
||||
..Default::default()
|
||||
}
|
||||
|
@ -402,8 +401,8 @@ impl<'a> From<Span<'a>> for Text<'a> {
|
|||
}
|
||||
|
||||
impl<'a> From<Line<'a>> for Text<'a> {
|
||||
fn from(line: Line<'a>) -> Text<'a> {
|
||||
Text {
|
||||
fn from(line: Line<'a>) -> Self {
|
||||
Self {
|
||||
lines: vec![line],
|
||||
..Default::default()
|
||||
}
|
||||
|
@ -411,8 +410,8 @@ impl<'a> From<Line<'a>> for Text<'a> {
|
|||
}
|
||||
|
||||
impl<'a> From<Vec<Line<'a>>> for Text<'a> {
|
||||
fn from(lines: Vec<Line<'a>>) -> Text<'a> {
|
||||
Text {
|
||||
fn from(lines: Vec<Line<'a>>) -> Self {
|
||||
Self {
|
||||
lines,
|
||||
..Default::default()
|
||||
}
|
||||
|
@ -425,7 +424,7 @@ where
|
|||
{
|
||||
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
|
||||
let lines = iter.into_iter().map(Into::into).collect();
|
||||
Text {
|
||||
Self {
|
||||
lines,
|
||||
..Default::default()
|
||||
}
|
||||
|
@ -486,7 +485,7 @@ impl WidgetRef for Text<'_> {
|
|||
}
|
||||
|
||||
impl<'a> Styled for Text<'a> {
|
||||
type Item = Text<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
|
|
@ -86,8 +86,8 @@ pub struct BarChart<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Default for BarChart<'a> {
|
||||
fn default() -> BarChart<'a> {
|
||||
BarChart {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
block: None,
|
||||
max: None,
|
||||
data: Vec::new(),
|
||||
|
@ -119,7 +119,7 @@ impl<'a> BarChart<'a> {
|
|||
/// .data(BarGroup::default().bars(&[Bar::default().value(10), Bar::default().value(20)]));
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn data(mut self, data: impl Into<BarGroup<'a>>) -> BarChart<'a> {
|
||||
pub fn data(mut self, data: impl Into<BarGroup<'a>>) -> Self {
|
||||
let group: BarGroup = data.into();
|
||||
if !group.bars.is_empty() {
|
||||
self.data.push(group);
|
||||
|
@ -129,7 +129,7 @@ impl<'a> BarChart<'a> {
|
|||
|
||||
/// Surround the [`BarChart`] with a [`Block`].
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn block(mut self, block: Block<'a>) -> BarChart<'a> {
|
||||
pub fn block(mut self, block: Block<'a>) -> Self {
|
||||
self.block = Some(block);
|
||||
self
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ impl<'a> BarChart<'a> {
|
|||
/// // f b b
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn max(mut self, max: u64) -> BarChart<'a> {
|
||||
pub const fn max(mut self, max: u64) -> Self {
|
||||
self.max = Some(max);
|
||||
self
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ impl<'a> BarChart<'a> {
|
|||
/// It is also possible to set individually the style of each [`Bar`].
|
||||
/// In this case the default style will be patched by the individual style
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn bar_style<S: Into<Style>>(mut self, style: S) -> BarChart<'a> {
|
||||
pub fn bar_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.bar_style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ impl<'a> BarChart<'a> {
|
|||
/// If not set, this defaults to `1`.
|
||||
/// The bar label also uses this value as its width.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn bar_width(mut self, width: u16) -> BarChart<'a> {
|
||||
pub const fn bar_width(mut self, width: u16) -> Self {
|
||||
self.bar_width = width;
|
||||
self
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ impl<'a> BarChart<'a> {
|
|||
/// // f b
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn bar_gap(mut self, gap: u16) -> BarChart<'a> {
|
||||
pub const fn bar_gap(mut self, gap: u16) -> Self {
|
||||
self.bar_gap = gap;
|
||||
self
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ impl<'a> BarChart<'a> {
|
|||
///
|
||||
/// If not set, the default is [`bar::NINE_LEVELS`](crate::symbols::bar::NINE_LEVELS).
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn bar_set(mut self, bar_set: symbols::bar::Set) -> BarChart<'a> {
|
||||
pub const fn bar_set(mut self, bar_set: symbols::bar::Set) -> Self {
|
||||
self.bar_set = bar_set;
|
||||
self
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ impl<'a> BarChart<'a> {
|
|||
///
|
||||
/// [`Bar::value_style`] to set the value style individually.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn value_style<S: Into<Style>>(mut self, style: S) -> BarChart<'a> {
|
||||
pub fn value_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.value_style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -257,14 +257,14 @@ impl<'a> BarChart<'a> {
|
|||
///
|
||||
/// [`Bar::label`] to set the label style individually.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn label_style<S: Into<Style>>(mut self, style: S) -> BarChart<'a> {
|
||||
pub fn label_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.label_style = style.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the gap between [`BarGroup`].
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn group_gap(mut self, gap: u16) -> BarChart<'a> {
|
||||
pub const fn group_gap(mut self, gap: u16) -> Self {
|
||||
self.group_gap = gap;
|
||||
self
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ impl<'a> BarChart<'a> {
|
|||
///
|
||||
/// The style will be applied to everything that isn't styled (borders, bars, labels, ...).
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> BarChart<'a> {
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ impl<'a> BarChart<'a> {
|
|||
/// █bar██
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn direction(mut self, direction: Direction) -> BarChart<'a> {
|
||||
pub const fn direction(mut self, direction: Direction) -> Self {
|
||||
self.direction = direction;
|
||||
self
|
||||
}
|
||||
|
@ -600,7 +600,7 @@ impl WidgetRef for BarChart<'_> {
|
|||
}
|
||||
|
||||
impl<'a> Styled for BarChart<'a> {
|
||||
type Item = BarChart<'a>;
|
||||
type Item = Self;
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ impl<'a> Bar<'a> {
|
|||
/// [`Bar::value_style`] to style the value.
|
||||
/// [`Bar::text_value`] to set the displayed value.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn value(mut self, value: u64) -> Bar<'a> {
|
||||
pub const fn value(mut self, value: u64) -> Self {
|
||||
self.value = value;
|
||||
self
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ impl<'a> Bar<'a> {
|
|||
/// display the label **in** the bar.
|
||||
/// See [`BarChart::direction`](crate::widgets::BarChart::direction) to set the direction.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn label(mut self, label: Line<'a>) -> Bar<'a> {
|
||||
pub fn label(mut self, label: Line<'a>) -> Self {
|
||||
self.label = Some(label);
|
||||
self
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ impl<'a> Bar<'a> {
|
|||
///
|
||||
/// This will apply to every non-styled element. It can be seen and used as a default value.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Bar<'a> {
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ impl<'a> Bar<'a> {
|
|||
///
|
||||
/// [`Bar::value`] to set the value.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn value_style<S: Into<Style>>(mut self, style: S) -> Bar<'a> {
|
||||
pub fn value_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.value_style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ impl<'a> Bar<'a> {
|
|||
///
|
||||
/// [`Bar::value`] to set the value.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn text_value(mut self, text_value: String) -> Bar<'a> {
|
||||
pub fn text_value(mut self, text_value: String) -> Self {
|
||||
self.text_value = Some(text_value);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@ pub struct BarGroup<'a> {
|
|||
impl<'a> BarGroup<'a> {
|
||||
/// Set the group label
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn label(mut self, label: Line<'a>) -> BarGroup<'a> {
|
||||
pub fn label(mut self, label: Line<'a>) -> Self {
|
||||
self.label = Some(label);
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the bars of the group to be shown
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn bars(mut self, bars: &[Bar<'a>]) -> BarGroup<'a> {
|
||||
pub fn bars(mut self, bars: &[Bar<'a>]) -> Self {
|
||||
self.bars = bars.to_vec();
|
||||
self
|
||||
}
|
||||
|
@ -65,8 +65,8 @@ impl<'a> BarGroup<'a> {
|
|||
}
|
||||
|
||||
impl<'a> From<&[(&'a str, u64)]> for BarGroup<'a> {
|
||||
fn from(value: &[(&'a str, u64)]) -> BarGroup<'a> {
|
||||
BarGroup {
|
||||
fn from(value: &[(&'a str, u64)]) -> Self {
|
||||
Self {
|
||||
label: None,
|
||||
bars: value
|
||||
.iter()
|
||||
|
@ -77,13 +77,13 @@ impl<'a> From<&[(&'a str, u64)]> for BarGroup<'a> {
|
|||
}
|
||||
|
||||
impl<'a, const N: usize> From<&[(&'a str, u64); N]> for BarGroup<'a> {
|
||||
fn from(value: &[(&'a str, u64); N]) -> BarGroup<'a> {
|
||||
fn from(value: &[(&'a str, u64); N]) -> Self {
|
||||
Self::from(value.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&Vec<(&'a str, u64)>> for BarGroup<'a> {
|
||||
fn from(value: &Vec<(&'a str, u64)>) -> BarGroup<'a> {
|
||||
fn from(value: &Vec<(&'a str, u64)>) -> Self {
|
||||
let array: &[(&str, u64)] = value;
|
||||
Self::from(array)
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ impl<'a> Block<'a> {
|
|||
|
||||
/// Create a new block with [all borders](Borders::ALL) shown
|
||||
pub const fn bordered() -> Self {
|
||||
let mut block = Block::new();
|
||||
let mut block = Self::new();
|
||||
block.borders = Borders::ALL;
|
||||
block
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ impl<'a> Block<'a> {
|
|||
/// - [`Block::title_alignment`]
|
||||
/// - [`Block::title_position`]
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn title<T>(mut self, title: T) -> Block<'a>
|
||||
pub fn title<T>(mut self, title: T) -> Self
|
||||
where
|
||||
T: Into<Title<'a>>,
|
||||
{
|
||||
|
@ -306,7 +306,7 @@ impl<'a> Block<'a> {
|
|||
///
|
||||
/// If a [`Title`] already has a style, the title's style will add on top of this one.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn title_style<S: Into<Style>>(mut self, style: S) -> Block<'a> {
|
||||
pub fn title_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.titles_style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ impl<'a> Block<'a> {
|
|||
/// .title_alignment(Alignment::Center);
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn title_alignment(mut self, alignment: Alignment) -> Block<'a> {
|
||||
pub const fn title_alignment(mut self, alignment: Alignment) -> Self {
|
||||
self.titles_alignment = alignment;
|
||||
self
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ impl<'a> Block<'a> {
|
|||
/// .title_position(Position::Bottom);
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn title_position(mut self, position: Position) -> Block<'a> {
|
||||
pub const fn title_position(mut self, position: Position) -> Self {
|
||||
self.titles_position = position;
|
||||
self
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ impl<'a> Block<'a> {
|
|||
/// .border_style(Style::new().blue());
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn border_style<S: Into<Style>>(mut self, style: S) -> Block<'a> {
|
||||
pub fn border_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.border_style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -398,7 +398,7 @@ impl<'a> Block<'a> {
|
|||
///
|
||||
/// This will also apply to the widget inside that block, unless the inner widget is styled.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Block<'a> {
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ impl<'a> Block<'a> {
|
|||
/// Block::default().borders(Borders::LEFT | Borders::RIGHT);
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn borders(mut self, flag: Borders) -> Block<'a> {
|
||||
pub const fn borders(mut self, flag: Borders) -> Self {
|
||||
self.borders = flag;
|
||||
self
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ impl<'a> Block<'a> {
|
|||
/// // ╰─────╯
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn border_type(mut self, border_type: BorderType) -> Block<'a> {
|
||||
pub const fn border_type(mut self, border_type: BorderType) -> Self {
|
||||
self.border_set = border_type.to_border_set();
|
||||
self
|
||||
}
|
||||
|
@ -466,7 +466,7 @@ impl<'a> Block<'a> {
|
|||
/// // ║ ║
|
||||
/// // ╚═════╝
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn border_set(mut self, border_set: border::Set) -> Block<'a> {
|
||||
pub const fn border_set(mut self, border_set: border::Set) -> Self {
|
||||
self.border_set = border_set;
|
||||
self
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ impl<'a> Block<'a> {
|
|||
/// // └───────────┘
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn padding(mut self, padding: Padding) -> Block<'a> {
|
||||
pub const fn padding(mut self, padding: Padding) -> Self {
|
||||
self.padding = padding;
|
||||
self
|
||||
}
|
||||
|
@ -850,7 +850,7 @@ impl BlockExt for Option<Block<'_>> {
|
|||
}
|
||||
|
||||
impl<'a> Styled for Block<'a> {
|
||||
type Item = Block<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
|
|
@ -88,7 +88,7 @@ pub enum Position {
|
|||
impl<'a> Title<'a> {
|
||||
/// Set the title content.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn content<T>(mut self, content: T) -> Title<'a>
|
||||
pub fn content<T>(mut self, content: T) -> Self
|
||||
where
|
||||
T: Into<Line<'a>>,
|
||||
{
|
||||
|
@ -98,14 +98,14 @@ impl<'a> Title<'a> {
|
|||
|
||||
/// Set the title alignment.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn alignment(mut self, alignment: Alignment) -> Title<'a> {
|
||||
pub const fn alignment(mut self, alignment: Alignment) -> Self {
|
||||
self.alignment = Some(alignment);
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the title position.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn position(mut self, position: Position) -> Title<'a> {
|
||||
pub const fn position(mut self, position: Position) -> Self {
|
||||
self.position = Some(position);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -439,9 +439,9 @@ impl<'a, 'b> Painter<'a, 'b> {
|
|||
}
|
||||
|
||||
impl<'a, 'b> From<&'a mut Context<'b>> for Painter<'a, 'b> {
|
||||
fn from(context: &'a mut Context<'b>) -> Painter<'a, 'b> {
|
||||
fn from(context: &'a mut Context<'b>) -> Self {
|
||||
let resolution = context.grid.resolution();
|
||||
Painter {
|
||||
Self {
|
||||
context,
|
||||
resolution,
|
||||
}
|
||||
|
@ -493,7 +493,7 @@ impl<'a> Context<'a> {
|
|||
x_bounds: [f64; 2],
|
||||
y_bounds: [f64; 2],
|
||||
marker: symbols::Marker,
|
||||
) -> Context<'a> {
|
||||
) -> Self {
|
||||
let dot = symbols::DOT.chars().next().unwrap();
|
||||
let block = symbols::block::FULL.chars().next().unwrap();
|
||||
let bar = symbols::bar::HALF.chars().next().unwrap();
|
||||
|
@ -504,7 +504,7 @@ impl<'a> Context<'a> {
|
|||
symbols::Marker::Braille => Box::new(BrailleGrid::new(width, height)),
|
||||
symbols::Marker::HalfBlock => Box::new(HalfBlockGrid::new(width, height)),
|
||||
};
|
||||
Context {
|
||||
Self {
|
||||
x_bounds,
|
||||
y_bounds,
|
||||
grid,
|
||||
|
@ -639,8 +639,8 @@ impl<'a, F> Default for Canvas<'a, F>
|
|||
where
|
||||
F: Fn(&mut Context),
|
||||
{
|
||||
fn default() -> Canvas<'a, F> {
|
||||
Canvas {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
block: None,
|
||||
x_bounds: [0.0, 0.0],
|
||||
y_bounds: [0.0, 0.0],
|
||||
|
@ -659,7 +659,7 @@ where
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn block(mut self, block: Block<'a>) -> Canvas<'a, F> {
|
||||
pub fn block(mut self, block: Block<'a>) -> Self {
|
||||
self.block = Some(block);
|
||||
self
|
||||
}
|
||||
|
@ -671,7 +671,7 @@ where
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn x_bounds(mut self, bounds: [f64; 2]) -> Canvas<'a, F> {
|
||||
pub const fn x_bounds(mut self, bounds: [f64; 2]) -> Self {
|
||||
self.x_bounds = bounds;
|
||||
self
|
||||
}
|
||||
|
@ -683,7 +683,7 @@ where
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn y_bounds(mut self, bounds: [f64; 2]) -> Canvas<'a, F> {
|
||||
pub const fn y_bounds(mut self, bounds: [f64; 2]) -> Self {
|
||||
self.y_bounds = bounds;
|
||||
self
|
||||
}
|
||||
|
@ -692,7 +692,7 @@ where
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn paint(mut self, f: F) -> Canvas<'a, F> {
|
||||
pub fn paint(mut self, f: F) -> Self {
|
||||
self.paint_func = Some(f);
|
||||
self
|
||||
}
|
||||
|
@ -701,7 +701,7 @@ where
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn background_color(mut self, color: Color) -> Canvas<'a, F> {
|
||||
pub const fn background_color(mut self, color: Color) -> Self {
|
||||
self.background_color = color;
|
||||
self
|
||||
}
|
||||
|
@ -745,7 +745,7 @@ where
|
|||
/// .paint(|ctx| {});
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn marker(mut self, marker: symbols::Marker) -> Canvas<'a, F> {
|
||||
pub const fn marker(mut self, marker: symbols::Marker) -> Self {
|
||||
self.marker = marker;
|
||||
self
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ impl<'a> Axis<'a> {
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn title<T>(mut self, title: T) -> Axis<'a>
|
||||
pub fn title<T>(mut self, title: T) -> Self
|
||||
where
|
||||
T: Into<Line<'a>>,
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ impl<'a> Axis<'a> {
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn bounds(mut self, bounds: [f64; 2]) -> Axis<'a> {
|
||||
pub const fn bounds(mut self, bounds: [f64; 2]) -> Self {
|
||||
self.bounds = bounds;
|
||||
self
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ impl<'a> Axis<'a> {
|
|||
/// .labels(vec!["0".bold(), "25".into(), "50".bold()]);
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn labels(mut self, labels: Vec<Span<'a>>) -> Axis<'a> {
|
||||
pub fn labels(mut self, labels: Vec<Span<'a>>) -> Self {
|
||||
self.labels = Some(labels);
|
||||
self
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ impl<'a> Axis<'a> {
|
|||
/// let axis = Axis::default().red();
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Axis<'a> {
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ impl<'a> Axis<'a> {
|
|||
///
|
||||
/// On the X axis, this parameter only affects the first label.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn labels_alignment(mut self, alignment: Alignment) -> Axis<'a> {
|
||||
pub const fn labels_alignment(mut self, alignment: Alignment) -> Self {
|
||||
self.labels_alignment = alignment;
|
||||
self
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ impl<'a> Dataset<'a> {
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn name<S>(mut self, name: S) -> Dataset<'a>
|
||||
pub fn name<S>(mut self, name: S) -> Self
|
||||
where
|
||||
S: Into<Line<'a>>,
|
||||
{
|
||||
|
@ -341,7 +341,7 @@ impl<'a> Dataset<'a> {
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn data(mut self, data: &'a [(f64, f64)]) -> Dataset<'a> {
|
||||
pub const fn data(mut self, data: &'a [(f64, f64)]) -> Self {
|
||||
self.data = data;
|
||||
self
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ impl<'a> Dataset<'a> {
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn marker(mut self, marker: symbols::Marker) -> Dataset<'a> {
|
||||
pub const fn marker(mut self, marker: symbols::Marker) -> Self {
|
||||
self.marker = marker;
|
||||
self
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ impl<'a> Dataset<'a> {
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn graph_type(mut self, graph_type: GraphType) -> Dataset<'a> {
|
||||
pub const fn graph_type(mut self, graph_type: GraphType) -> Self {
|
||||
self.graph_type = graph_type;
|
||||
self
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ impl<'a> Dataset<'a> {
|
|||
/// let dataset = Dataset::default().red();
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Dataset<'a> {
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -527,8 +527,8 @@ impl<'a> Chart<'a> {
|
|||
/// Dataset::default().data(&data_points2),
|
||||
/// ]);
|
||||
/// ```
|
||||
pub fn new(datasets: Vec<Dataset<'a>>) -> Chart<'a> {
|
||||
Chart {
|
||||
pub fn new(datasets: Vec<Dataset<'a>>) -> Self {
|
||||
Self {
|
||||
block: None,
|
||||
x_axis: Axis::default(),
|
||||
y_axis: Axis::default(),
|
||||
|
@ -543,7 +543,7 @@ impl<'a> Chart<'a> {
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn block(mut self, block: Block<'a>) -> Chart<'a> {
|
||||
pub fn block(mut self, block: Block<'a>) -> Self {
|
||||
self.block = Some(block);
|
||||
self
|
||||
}
|
||||
|
@ -557,7 +557,7 @@ impl<'a> Chart<'a> {
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Chart<'a> {
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -580,7 +580,7 @@ impl<'a> Chart<'a> {
|
|||
/// );
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn x_axis(mut self, axis: Axis<'a>) -> Chart<'a> {
|
||||
pub fn x_axis(mut self, axis: Axis<'a>) -> Self {
|
||||
self.x_axis = axis;
|
||||
self
|
||||
}
|
||||
|
@ -603,7 +603,7 @@ impl<'a> Chart<'a> {
|
|||
/// );
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn y_axis(mut self, axis: Axis<'a>) -> Chart<'a> {
|
||||
pub fn y_axis(mut self, axis: Axis<'a>) -> Self {
|
||||
self.y_axis = axis;
|
||||
self
|
||||
}
|
||||
|
@ -651,7 +651,7 @@ impl<'a> Chart<'a> {
|
|||
pub const fn hidden_legend_constraints(
|
||||
mut self,
|
||||
constraints: (Constraint, Constraint),
|
||||
) -> Chart<'a> {
|
||||
) -> Self {
|
||||
self.hidden_legend_constraints = constraints;
|
||||
self
|
||||
}
|
||||
|
@ -686,7 +686,7 @@ impl<'a> Chart<'a> {
|
|||
/// let chart = Chart::new(vec![]).legend_position(None);
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn legend_position(mut self, position: Option<LegendPosition>) -> Chart<'a> {
|
||||
pub const fn legend_position(mut self, position: Option<LegendPosition>) -> Self {
|
||||
self.legend_position = position;
|
||||
self
|
||||
}
|
||||
|
@ -1063,7 +1063,7 @@ impl WidgetRef for Chart<'_> {
|
|||
}
|
||||
|
||||
impl<'a> Styled for Axis<'a> {
|
||||
type Item = Axis<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
@ -1075,7 +1075,7 @@ impl<'a> Styled for Axis<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Styled for Dataset<'a> {
|
||||
type Item = Dataset<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
@ -1087,7 +1087,7 @@ impl<'a> Styled for Dataset<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Styled for Chart<'a> {
|
||||
type Item = Chart<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
|
|
@ -41,8 +41,8 @@ pub struct Gauge<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Default for Gauge<'a> {
|
||||
fn default() -> Gauge<'a> {
|
||||
Gauge {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
block: None,
|
||||
ratio: 0.0,
|
||||
label: None,
|
||||
|
@ -59,7 +59,7 @@ impl<'a> Gauge<'a> {
|
|||
/// The gauge is rendered in the inner portion of the block once space for borders and padding
|
||||
/// is reserved. Styles set on the block do **not** affect the bar itself.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn block(mut self, block: Block<'a>) -> Gauge<'a> {
|
||||
pub fn block(mut self, block: Block<'a>) -> Self {
|
||||
self.block = Some(block);
|
||||
self
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ impl<'a> Gauge<'a> {
|
|||
///
|
||||
/// See [`Gauge::ratio`] to set from a float.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn percent(mut self, percent: u16) -> Gauge<'a> {
|
||||
pub fn percent(mut self, percent: u16) -> Self {
|
||||
assert!(
|
||||
percent <= 100,
|
||||
"Percentage should be between 0 and 100 inclusively."
|
||||
|
@ -96,7 +96,7 @@ impl<'a> Gauge<'a> {
|
|||
///
|
||||
/// See [`Gauge::percent`] to set from a percentage.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn ratio(mut self, ratio: f64) -> Gauge<'a> {
|
||||
pub fn ratio(mut self, ratio: f64) -> Self {
|
||||
assert!(
|
||||
(0.0..=1.0).contains(&ratio),
|
||||
"Ratio should be between 0 and 1 inclusively."
|
||||
|
@ -110,7 +110,7 @@ impl<'a> Gauge<'a> {
|
|||
/// For a left-aligned label, see [`LineGauge`].
|
||||
/// If the label is not defined, it is the percentage filled.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn label<T>(mut self, label: T) -> Gauge<'a>
|
||||
pub fn label<T>(mut self, label: T) -> Self
|
||||
where
|
||||
T: Into<Span<'a>>,
|
||||
{
|
||||
|
@ -126,7 +126,7 @@ impl<'a> Gauge<'a> {
|
|||
/// This will style the block (if any non-styled) and background of the widget (everything
|
||||
/// except the bar itself). [`Block`] style set with [`Gauge::block`] takes precedence.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Gauge<'a> {
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ impl<'a> Gauge<'a> {
|
|||
/// `style` accepts any type that is convertible to [`Style`] (e.g. [`Style`], [`Color`], or
|
||||
/// your own type that implements [`Into<Style>`]).
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn gauge_style<S: Into<Style>>(mut self, style: S) -> Gauge<'a> {
|
||||
pub fn gauge_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.gauge_style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ impl<'a> Gauge<'a> {
|
|||
/// [unicode block characters](https://en.wikipedia.org/wiki/Block_Elements).
|
||||
/// This is useful to display a higher precision bar (8 extra fractional parts per cell).
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn use_unicode(mut self, unicode: bool) -> Gauge<'a> {
|
||||
pub const fn use_unicode(mut self, unicode: bool) -> Self {
|
||||
self.use_unicode = unicode;
|
||||
self
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ impl WidgetRef for LineGauge<'_> {
|
|||
}
|
||||
|
||||
impl<'a> Styled for Gauge<'a> {
|
||||
type Item = Gauge<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
@ -415,7 +415,7 @@ impl<'a> Styled for Gauge<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Styled for LineGauge<'a> {
|
||||
type Item = LineGauge<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
|
|
@ -252,11 +252,11 @@ impl<'a> ListItem<'a> {
|
|||
/// # See also
|
||||
///
|
||||
/// - [`List::new`] to create a list of items that can be converted to [`ListItem`]
|
||||
pub fn new<T>(content: T) -> ListItem<'a>
|
||||
pub fn new<T>(content: T) -> Self
|
||||
where
|
||||
T: Into<Text<'a>>,
|
||||
{
|
||||
ListItem {
|
||||
Self {
|
||||
content: content.into(),
|
||||
style: Style::default(),
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ impl<'a> ListItem<'a> {
|
|||
/// let item = ListItem::new("Item 1").red().italic();
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> ListItem<'a> {
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ where
|
|||
T: Into<Text<'a>>,
|
||||
{
|
||||
fn from(value: T) -> Self {
|
||||
ListItem::new(value)
|
||||
Self::new(value)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -489,12 +489,12 @@ impl<'a> List<'a> {
|
|||
/// let empty_list = List::default();
|
||||
/// let filled_list = empty_list.items(["Item 1"]);
|
||||
/// ```
|
||||
pub fn new<T>(items: T) -> List<'a>
|
||||
pub fn new<T>(items: T) -> Self
|
||||
where
|
||||
T: IntoIterator,
|
||||
T::Item: Into<ListItem<'a>>,
|
||||
{
|
||||
List {
|
||||
Self {
|
||||
block: None,
|
||||
style: Style::default(),
|
||||
items: items.into_iter().map(|i| i.into()).collect(),
|
||||
|
@ -541,7 +541,7 @@ impl<'a> List<'a> {
|
|||
/// let list = List::new(items).block(block);
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn block(mut self, block: Block<'a>) -> List<'a> {
|
||||
pub fn block(mut self, block: Block<'a>) -> Self {
|
||||
self.block = Some(block);
|
||||
self
|
||||
}
|
||||
|
@ -575,7 +575,7 @@ impl<'a> List<'a> {
|
|||
/// let list = List::new(items).red().italic();
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> List<'a> {
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -594,7 +594,7 @@ impl<'a> List<'a> {
|
|||
/// let list = List::new(items).highlight_symbol(">>");
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn highlight_symbol(mut self, highlight_symbol: &'a str) -> List<'a> {
|
||||
pub const fn highlight_symbol(mut self, highlight_symbol: &'a str) -> Self {
|
||||
self.highlight_symbol = Some(highlight_symbol);
|
||||
self
|
||||
}
|
||||
|
@ -618,7 +618,7 @@ impl<'a> List<'a> {
|
|||
/// let list = List::new(items).highlight_style(Style::new().red().italic());
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn highlight_style<S: Into<Style>>(mut self, style: S) -> List<'a> {
|
||||
pub fn highlight_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.highlight_style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -629,7 +629,7 @@ impl<'a> List<'a> {
|
|||
///
|
||||
/// This is a fluent setter method which must be chained or used as it consumes self
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn repeat_highlight_symbol(mut self, repeat: bool) -> List<'a> {
|
||||
pub const fn repeat_highlight_symbol(mut self, repeat: bool) -> Self {
|
||||
self.repeat_highlight_symbol = repeat;
|
||||
self
|
||||
}
|
||||
|
@ -682,7 +682,7 @@ impl<'a> List<'a> {
|
|||
/// let list = List::new(items).direction(ListDirection::BottomToTop);
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn direction(mut self, direction: ListDirection) -> List<'a> {
|
||||
pub const fn direction(mut self, direction: ListDirection) -> Self {
|
||||
self.direction = direction;
|
||||
self
|
||||
}
|
||||
|
@ -701,7 +701,7 @@ impl<'a> List<'a> {
|
|||
/// let list = List::new(items).scroll_padding(1);
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn scroll_padding(mut self, padding: usize) -> List<'a> {
|
||||
pub const fn scroll_padding(mut self, padding: usize) -> Self {
|
||||
self.scroll_padding = padding;
|
||||
self
|
||||
}
|
||||
|
@ -740,7 +740,7 @@ impl<'a> List<'a> {
|
|||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
#[deprecated(since = "0.25.0", note = "You should use `List::direction` instead.")]
|
||||
pub fn start_corner(self, corner: Corner) -> List<'a> {
|
||||
pub fn start_corner(self, corner: Corner) -> Self {
|
||||
if corner == Corner::BottomLeft {
|
||||
self.direction(ListDirection::BottomToTop)
|
||||
} else {
|
||||
|
@ -1009,7 +1009,7 @@ impl StatefulWidgetRef for List<'_> {
|
|||
}
|
||||
|
||||
impl<'a> Styled for List<'a> {
|
||||
type Item = List<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
@ -1021,7 +1021,7 @@ impl<'a> Styled for List<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Styled for ListItem<'a> {
|
||||
type Item = ListItem<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
@ -1037,7 +1037,7 @@ where
|
|||
Item: Into<ListItem<'a>>,
|
||||
{
|
||||
fn from_iter<Iter: IntoIterator<Item = Item>>(iter: Iter) -> Self {
|
||||
List::new(iter)
|
||||
Self::new(iter)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,11 +107,11 @@ impl<'a> Paragraph<'a> {
|
|||
/// let paragraph = Paragraph::new(Text::styled("Hello, world!", Style::default()));
|
||||
/// let paragraph = Paragraph::new(Line::from(vec!["Hello, ".into(), "world!".red()]));
|
||||
/// ```
|
||||
pub fn new<T>(text: T) -> Paragraph<'a>
|
||||
pub fn new<T>(text: T) -> Self
|
||||
where
|
||||
T: Into<Text<'a>>,
|
||||
{
|
||||
Paragraph {
|
||||
Self {
|
||||
block: None,
|
||||
style: Style::default(),
|
||||
wrap: None,
|
||||
|
@ -131,7 +131,7 @@ impl<'a> Paragraph<'a> {
|
|||
/// .block(Block::default().title("Paragraph").borders(Borders::ALL));
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn block(mut self, block: Block<'a>) -> Paragraph<'a> {
|
||||
pub fn block(mut self, block: Block<'a>) -> Self {
|
||||
self.block = Some(block);
|
||||
self
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ impl<'a> Paragraph<'a> {
|
|||
/// let paragraph = Paragraph::new("Hello, world!").style(Style::new().red().on_white());
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Paragraph<'a> {
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ impl<'a> Paragraph<'a> {
|
|||
/// let paragraph = Paragraph::new("Hello, world!").wrap(Wrap { trim: true });
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn wrap(mut self, wrap: Wrap) -> Paragraph<'a> {
|
||||
pub const fn wrap(mut self, wrap: Wrap) -> Self {
|
||||
self.wrap = Some(wrap);
|
||||
self
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ impl<'a> Paragraph<'a> {
|
|||
/// For more information about future scrolling design and concerns, see [RFC: Design of
|
||||
/// Scrollable Widgets](https://github.com/ratatui-org/ratatui/issues/174) on GitHub.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn scroll(mut self, offset: (Vertical, Horizontal)) -> Paragraph<'a> {
|
||||
pub const fn scroll(mut self, offset: (Vertical, Horizontal)) -> Self {
|
||||
self.scroll = offset;
|
||||
self
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ impl<'a> Paragraph<'a> {
|
|||
/// let paragraph = Paragraph::new("Hello World").alignment(Alignment::Center);
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn alignment(mut self, alignment: Alignment) -> Paragraph<'a> {
|
||||
pub const fn alignment(mut self, alignment: Alignment) -> Self {
|
||||
self.alignment = alignment;
|
||||
self
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ impl<'a> Paragraph<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Styled for Paragraph<'a> {
|
||||
type Item = Paragraph<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
|
|
@ -48,8 +48,8 @@ where
|
|||
O: Iterator<Item = (I, Alignment)>,
|
||||
I: Iterator<Item = StyledGrapheme<'a>>,
|
||||
{
|
||||
pub fn new(lines: O, max_line_width: u16, trim: bool) -> WordWrapper<'a, O, I> {
|
||||
WordWrapper {
|
||||
pub fn new(lines: O, max_line_width: u16, trim: bool) -> Self {
|
||||
Self {
|
||||
input_lines: lines,
|
||||
max_line_width,
|
||||
wrapped_lines: None,
|
||||
|
@ -243,8 +243,8 @@ where
|
|||
O: Iterator<Item = (I, Alignment)>,
|
||||
I: Iterator<Item = StyledGrapheme<'a>>,
|
||||
{
|
||||
pub fn new(lines: O, max_line_width: u16) -> LineTruncator<'a, O, I> {
|
||||
LineTruncator {
|
||||
pub fn new(lines: O, max_line_width: u16) -> Self {
|
||||
Self {
|
||||
input_lines: lines,
|
||||
max_line_width,
|
||||
horizontal_offset: 0,
|
||||
|
|
|
@ -60,8 +60,8 @@ pub enum RenderDirection {
|
|||
}
|
||||
|
||||
impl<'a> Default for Sparkline<'a> {
|
||||
fn default() -> Sparkline<'a> {
|
||||
Sparkline {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
block: None,
|
||||
style: Style::default(),
|
||||
data: &[],
|
||||
|
@ -75,7 +75,7 @@ impl<'a> Default for Sparkline<'a> {
|
|||
impl<'a> Sparkline<'a> {
|
||||
/// Wraps the sparkline with the given `block`.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn block(mut self, block: Block<'a>) -> Sparkline<'a> {
|
||||
pub fn block(mut self, block: Block<'a>) -> Self {
|
||||
self.block = Some(block);
|
||||
self
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ impl<'a> Sparkline<'a> {
|
|||
///
|
||||
/// The foreground corresponds to the bars while the background is everything else.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Sparkline<'a> {
|
||||
pub fn style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ impl<'a> Sparkline<'a> {
|
|||
/// # }
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn data(mut self, data: &'a [u64]) -> Sparkline<'a> {
|
||||
pub const fn data(mut self, data: &'a [u64]) -> Self {
|
||||
self.data = data;
|
||||
self
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ impl<'a> Sparkline<'a> {
|
|||
/// Every bar will be scaled accordingly. If no max is given, this will be the max in the
|
||||
/// dataset.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn max(mut self, max: u64) -> Sparkline<'a> {
|
||||
pub const fn max(mut self, max: u64) -> Self {
|
||||
self.max = Some(max);
|
||||
self
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ impl<'a> Sparkline<'a> {
|
|||
/// Can be [`symbols::bar::THREE_LEVELS`], [`symbols::bar::NINE_LEVELS`] (default) or a custom
|
||||
/// [`Set`](symbols::bar::Set).
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn bar_set(mut self, bar_set: symbols::bar::Set) -> Sparkline<'a> {
|
||||
pub const fn bar_set(mut self, bar_set: symbols::bar::Set) -> Self {
|
||||
self.bar_set = bar_set;
|
||||
self
|
||||
}
|
||||
|
@ -134,14 +134,14 @@ impl<'a> Sparkline<'a> {
|
|||
///
|
||||
/// [`RenderDirection::LeftToRight`] by default.
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn direction(mut self, direction: RenderDirection) -> Sparkline<'a> {
|
||||
pub const fn direction(mut self, direction: RenderDirection) -> Self {
|
||||
self.direction = direction;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Styled for Sparkline<'a> {
|
||||
type Item = Sparkline<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
|
|
@ -142,8 +142,8 @@ impl<'a, T> From<T> for Cell<'a>
|
|||
where
|
||||
T: Into<Text<'a>>,
|
||||
{
|
||||
fn from(content: T) -> Cell<'a> {
|
||||
Cell {
|
||||
fn from(content: T) -> Self {
|
||||
Self {
|
||||
content: content.into(),
|
||||
style: Style::default(),
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ where
|
|||
}
|
||||
|
||||
impl<'a> Styled for Cell<'a> {
|
||||
type Item = Cell<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
|
|
@ -232,7 +232,7 @@ impl Row<'_> {
|
|||
}
|
||||
|
||||
impl<'a> Styled for Row<'a> {
|
||||
type Item = Row<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
@ -248,7 +248,7 @@ where
|
|||
Item: Into<Cell<'a>>,
|
||||
{
|
||||
fn from_iter<IterCells: IntoIterator<Item = Item>>(cells: IterCells) -> Self {
|
||||
Row::new(cells)
|
||||
Self::new(cells)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -812,7 +812,7 @@ fn ensure_percentages_less_than_100(widths: &[Constraint]) {
|
|||
}
|
||||
|
||||
impl<'a> Styled for Table<'a> {
|
||||
type Item = Table<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
@ -833,7 +833,7 @@ where
|
|||
/// `Table::widths` after construction.
|
||||
fn from_iter<Iter: IntoIterator<Item = Item>>(rows: Iter) -> Self {
|
||||
let widths: [Constraint; 0] = [];
|
||||
Table::new(rows, widths)
|
||||
Self::new(rows, widths)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,12 +84,12 @@ impl<'a> Tabs<'a> {
|
|||
/// # use ratatui::{prelude::*, widgets::Tabs};
|
||||
/// let tabs = Tabs::new(vec!["Tab 1".red(), "Tab 2".blue()]);
|
||||
/// ```
|
||||
pub fn new<Iter>(titles: Iter) -> Tabs<'a>
|
||||
pub fn new<Iter>(titles: Iter) -> Self
|
||||
where
|
||||
Iter: IntoIterator,
|
||||
Iter::Item: Into<Line<'a>>,
|
||||
{
|
||||
Tabs {
|
||||
Self {
|
||||
block: None,
|
||||
titles: titles.into_iter().map(Into::into).collect(),
|
||||
selected: 0,
|
||||
|
@ -103,7 +103,7 @@ impl<'a> Tabs<'a> {
|
|||
|
||||
/// Surrounds the `Tabs` with a [`Block`].
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn block(mut self, block: Block<'a>) -> Tabs<'a> {
|
||||
pub fn block(mut self, block: Block<'a>) -> Self {
|
||||
self.block = Some(block);
|
||||
self
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ impl<'a> Tabs<'a> {
|
|||
/// The first tab has index 0 (this is also the default index).
|
||||
/// The selected tab can have a different style with [`Tabs::highlight_style`].
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub const fn select(mut self, selected: usize) -> Tabs<'a> {
|
||||
pub const fn select(mut self, selected: usize) -> Self {
|
||||
self.selected = selected;
|
||||
self
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ impl<'a> Tabs<'a> {
|
|||
///
|
||||
/// Highlighted tab can be selected with [`Tabs::select`].
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn highlight_style<S: Into<Style>>(mut self, style: S) -> Tabs<'a> {
|
||||
pub fn highlight_style<S: Into<Style>>(mut self, style: S) -> Self {
|
||||
self.highlight_style = style.into();
|
||||
self
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ impl<'a> Tabs<'a> {
|
|||
/// let tabs = Tabs::new(vec!["Tab 1", "Tab 2"]).divider("-");
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn divider<T>(mut self, divider: T) -> Tabs<'a>
|
||||
pub fn divider<T>(mut self, divider: T) -> Self
|
||||
where
|
||||
T: Into<Span<'a>>,
|
||||
{
|
||||
|
@ -186,7 +186,7 @@ impl<'a> Tabs<'a> {
|
|||
/// let tabs = Tabs::new(vec!["Tab 1", "Tab 2"]).padding("", "");
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn padding<T, U>(mut self, left: T, right: U) -> Tabs<'a>
|
||||
pub fn padding<T, U>(mut self, left: T, right: U) -> Self
|
||||
where
|
||||
T: Into<Line<'a>>,
|
||||
U: Into<Line<'a>>,
|
||||
|
@ -208,7 +208,7 @@ impl<'a> Tabs<'a> {
|
|||
/// let tabs = Tabs::new(vec!["Tab 1", "Tab 2"]).padding_left("->");
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn padding_left<T>(mut self, padding: T) -> Tabs<'a>
|
||||
pub fn padding_left<T>(mut self, padding: T) -> Self
|
||||
where
|
||||
T: Into<Line<'a>>,
|
||||
{
|
||||
|
@ -228,7 +228,7 @@ impl<'a> Tabs<'a> {
|
|||
/// let tabs = Tabs::new(vec!["Tab 1", "Tab 2"]).padding_right("<-");
|
||||
/// ```
|
||||
#[must_use = "method moves the value of self and returns the modified value"]
|
||||
pub fn padding_right<T>(mut self, padding: T) -> Tabs<'a>
|
||||
pub fn padding_right<T>(mut self, padding: T) -> Self
|
||||
where
|
||||
T: Into<Line<'a>>,
|
||||
{
|
||||
|
@ -238,7 +238,7 @@ impl<'a> Tabs<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Styled for Tabs<'a> {
|
||||
type Item = Tabs<'a>;
|
||||
type Item = Self;
|
||||
|
||||
fn style(&self) -> Style {
|
||||
self.style
|
||||
|
|
Loading…
Reference in a new issue