Skip to content

Commit

Permalink
Merge pull request #237 from TitouanReal/width/height-api-improvement
Browse files Browse the repository at this point in the history
Replace Length with impl Into<Length> in width/height APIs
  • Loading branch information
genusistimelord authored Apr 30, 2024
2 parents 8e2b738 + 69d5657 commit 898cf99
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 38 deletions.
8 changes: 4 additions & 4 deletions src/widgets/badge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ where

/// Sets the height of the [`Badge`].
#[must_use]
pub fn height(mut self, height: Length) -> Self {
self.height = height;
pub fn height(mut self, height: impl Into<Length>) -> Self {
self.height = height.into();
self
}

Expand All @@ -115,8 +115,8 @@ where

/// Sets the width of the [`Badge`].
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
pub fn width(mut self, width: impl Into<Length>) -> Self {
self.width = width.into();
self
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/widgets/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ where

/// Sets the height of the [`Card`].
#[must_use]
pub fn height(mut self, height: Length) -> Self {
self.height = height;
pub fn height(mut self, height: impl Into<Length>) -> Self {
self.height = height.into();
self
}

Expand Down Expand Up @@ -200,8 +200,8 @@ where

/// Sets the width of the [`Card`].
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
pub fn width(mut self, width: impl Into<Length>) -> Self {
self.width = width.into();
self
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/widgets/cupertino/cupertino_spinner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ impl CupertinoSpinner {

/// Sets the height of the [`CupertinoSpinner`].
#[must_use]
pub fn height(mut self, height: Length) -> Self {
self.height = height;
pub fn height(mut self, height: impl Into<Length>) -> Self {
self.height = height.into();
self
}

Expand All @@ -92,8 +92,8 @@ impl CupertinoSpinner {

/// Sets the width of the [`CupertinoSpinner`].
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
pub fn width(mut self, width: impl Into<Length>) -> Self {
self.width = width.into();
self
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/number_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ where

/// Sets the width of the [`NumberInput`].
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
pub fn width(mut self, width: impl Into<Length>) -> Self {
self.width = width.into();
self
}

Expand Down
8 changes: 4 additions & 4 deletions src/widgets/segmented_button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ where

/// Sets the width of the [`SegmentedButton`](SegmentedButton).
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
pub fn width(mut self, width: impl Into<Length>) -> Self {
self.width = width.into();
self
}

/// Sets the height of the [`SegmentedButton`](SegmentedButton).
#[must_use]
pub fn height(mut self, height: Length) -> Self {
self.height = height;
pub fn height(mut self, height: impl Into<Length>) -> Self {
self.height = height.into();
self
}

Expand Down
8 changes: 4 additions & 4 deletions src/widgets/selection_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ where

/// Sets the width of the [`SelectionList`].
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
pub fn width(mut self, width: impl Into<Length>) -> Self {
self.width = width.into();
self
}

/// Sets the height of the [`SelectionList`].
#[must_use]
pub fn height(mut self, height: Length) -> Self {
self.height = height;
pub fn height(mut self, height: impl Into<Length>) -> Self {
self.height = height.into();
self
}

Expand Down
8 changes: 4 additions & 4 deletions src/widgets/spinner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ impl Spinner {

/// Sets the width of the [`Spinner`].
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
pub fn width(mut self, width: impl Into<Length>) -> Self {
self.width = width.into();
self
}

/// Sets the height of the [`Spinner`].
#[must_use]
pub fn height(mut self, height: Length) -> Self {
self.height = height;
pub fn height(mut self, height: impl Into<Length>) -> Self {
self.height = height.into();
self
}

Expand Down
8 changes: 4 additions & 4 deletions src/widgets/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ where

/// Sets the width of the [`Split`].
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
pub fn width(mut self, width: impl Into<Length>) -> Self {
self.width = width.into();
self
}

/// Sets the height of the [`Split`].
#[must_use]
pub fn height(mut self, height: Length) -> Self {
self.height = height;
pub fn height(mut self, height: impl Into<Length>) -> Self {
self.height = height.into();
self
}

Expand Down
8 changes: 4 additions & 4 deletions src/widgets/tab_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ where

/// Sets the height of the [`TabBar`].
#[must_use]
pub fn height(mut self, height: Length) -> Self {
self.height = height;
pub fn height(mut self, height: impl Into<Length>) -> Self {
self.height = height.into();
self
}

Expand Down Expand Up @@ -332,8 +332,8 @@ where

/// Sets the width of the [`TabBar`].
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
pub fn width(mut self, width: impl Into<Length>) -> Self {
self.width = width.into();
self
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/widgets/tabs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ where

/// Sets the height of the [`Tabs`].
#[must_use]
pub fn height(mut self, height: Length) -> Self {
self.height = height;
pub fn height(mut self, height: impl Into<Length>) -> Self {
self.height = height.into();
self
}

Expand Down Expand Up @@ -282,8 +282,8 @@ where

/// Sets the width of the [`Tabs`].
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
pub fn width(mut self, width: impl Into<Length>) -> Self {
self.width = width.into();
self
}
}
Expand Down

0 comments on commit 898cf99

Please sign in to comment.