Skip to content

Commit

Permalink
refactor(renderer): Make functions const
Browse files Browse the repository at this point in the history
  • Loading branch information
Muscraft committed Dec 2, 2023
1 parent 881d164 commit d87d015
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ impl Renderer {
}

/// No terminal styling
pub fn plain() -> Self {
pub const fn plain() -> Self {
Self {
anonymized_line_numbers: false,
margin: None,
stylesheet: StyleSheet::default(),
stylesheet: StyleSheet::const_default(),
}
}

/// Default terminal styling
pub fn styled() -> Self {
pub const fn styled() -> Self {
Self {
anonymized_line_numbers: false,
margin: None,
Expand All @@ -50,52 +50,52 @@ impl Renderer {
}
}

pub fn anonymized_line_numbers(mut self, anonymized_line_numbers: bool) -> Self {
pub const fn anonymized_line_numbers(mut self, anonymized_line_numbers: bool) -> Self {
self.anonymized_line_numbers = anonymized_line_numbers;
self
}

pub fn margin(mut self, margin: Option<Margin>) -> Self {
pub const fn margin(mut self, margin: Option<Margin>) -> Self {
self.margin = margin;
self
}

pub fn error(mut self, style: Style) -> Self {
pub const fn error(mut self, style: Style) -> Self {
self.stylesheet.error = style;
self
}

pub fn warning(mut self, style: Style) -> Self {
pub const fn warning(mut self, style: Style) -> Self {
self.stylesheet.warning = style;
self
}

pub fn info(mut self, style: Style) -> Self {
pub const fn info(mut self, style: Style) -> Self {
self.stylesheet.info = style;
self
}

pub fn note(mut self, style: Style) -> Self {
pub const fn note(mut self, style: Style) -> Self {
self.stylesheet.note = style;
self
}

pub fn help(mut self, style: Style) -> Self {
pub const fn help(mut self, style: Style) -> Self {
self.stylesheet.help = style;
self
}

pub fn line_no(mut self, style: Style) -> Self {
pub const fn line_no(mut self, style: Style) -> Self {
self.stylesheet.line_no = style;
self
}

pub fn emphasis(mut self, style: Style) -> Self {
pub const fn emphasis(mut self, style: Style) -> Self {
self.stylesheet.emphasis = style;
self
}

pub fn none(mut self, style: Style) -> Self {
pub const fn none(mut self, style: Style) -> Self {
self.stylesheet.none = style;
self
}
Expand Down

0 comments on commit d87d015

Please sign in to comment.