refactor(cell): must_use and simplify style() (#1124)

<!-- Please read CONTRIBUTING.md before submitting any pull request. -->
This commit is contained in:
EdJoPaTo 2024-05-22 08:26:32 +02:00 committed by GitHub
parent 70df102de0
commit 257db6257f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -35,6 +35,7 @@ pub struct Cell {
impl Cell {
/// Gets the symbol of the cell.
#[must_use]
pub fn symbol(&self) -> &str {
self.symbol.as_str()
}
@ -86,19 +87,16 @@ impl Cell {
}
/// Returns the style of the cell.
pub fn style(&self) -> Style {
#[cfg(feature = "underline-color")]
return Style::default()
.fg(self.fg)
.bg(self.bg)
.underline_color(self.underline_color)
.add_modifier(self.modifier);
#[cfg(not(feature = "underline-color"))]
return Style::default()
.fg(self.fg)
.bg(self.bg)
.add_modifier(self.modifier);
#[must_use]
pub const fn style(&self) -> Style {
Style {
fg: Some(self.fg),
bg: Some(self.bg),
#[cfg(feature = "underline-color")]
underline_color: Some(self.underline_color),
add_modifier: self.modifier,
sub_modifier: Modifier::empty(),
}
}
/// Sets the cell to be skipped when copying (diffing) the buffer to the screen.