Skip to content

Commit

Permalink
refactor(cell): must_use and simplify style() (#1124)
Browse files Browse the repository at this point in the history
<!-- Please read CONTRIBUTING.md before submitting any pull request. -->
  • Loading branch information
EdJoPaTo committed May 22, 2024
1 parent 70df102 commit 257db62
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/buffer/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 257db62

Please sign in to comment.