chore: Revert "Make Stylize's .bg(color) generic" (#1102)

This reverts commit ec763af851 from #1099
This commit is contained in:
Dheepak Krishnamurthy 2024-05-12 19:05:00 -04:00 committed by GitHub
parent 366cbae09f
commit 76e5fe5a9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 17 deletions

View file

@ -10,8 +10,6 @@ GitHub with a [breaking change] label.
This is a quick summary of the sections below:
- [v0.26.1](#v0261)
- `Stylize::bg()` now accepts `Into<Color>`
- [v0.26.0](#v0260)
- `Flex::Start` is the new default flex mode for `Layout`
- `patch_style` & `reset_style` now consume and return `Self`
@ -49,14 +47,6 @@ This is a quick summary of the sections below:
- MSRV is now 1.63.0
- `List` no longer ignores empty strings
## [v0.26.1](https://github.com/ratatui-org/ratatui/releases/tag/v0.26.1)
### `Stylize::bg()` now accepts `Into<Color>` ([#1099])
[#1099]: https://github.com/ratatui-org/ratatui/pull/1099
Previously, `Stylize::bg()` accepted `Color` but now accepts `Into<Color>`. This allows more flexible types from calling scopes, though it can break some type inference in the calling scope.
## [v0.26.0](https://github.com/ratatui-org/ratatui/releases/tag/v0.26.0)
### `Flex::Start` is the new default flex mode for `Layout` ([#881])

View file

@ -137,9 +137,9 @@ macro_rules! modifier {
/// ```
pub trait Stylize<'a, T>: Sized {
#[must_use = "`bg` returns the modified style without modifying the original"]
fn bg<C: Into<Color>>(self, color: C) -> T;
fn bg(self, color: Color) -> T;
#[must_use = "`fg` returns the modified style without modifying the original"]
fn fg<C: Into<Color>>(self, color: C) -> T;
fn fg<S: Into<Color>>(self, color: S) -> T;
#[must_use = "`reset` returns the modified style without modifying the original"]
fn reset(self) -> T;
#[must_use = "`add_modifier` returns the modified style without modifying the original"]
@ -179,12 +179,12 @@ impl<'a, T, U> Stylize<'a, T> for U
where
U: Styled<Item = T>,
{
fn bg<C: Into<Color>>(self, color: C) -> T {
let style = self.style().bg(color.into());
fn bg(self, color: Color) -> T {
let style = self.style().bg(color);
self.set_style(style)
}
fn fg<C: Into<Color>>(self, color: C) -> T {
fn fg<S: Into<Color>>(self, color: S) -> T {
let style = self.style().fg(color.into());
self.set_style(style)
}