Skip to content

Commit

Permalink
Merge pull request #51 from est31/const_fn
Browse files Browse the repository at this point in the history
Turn EncodeConfig functions const fn
  • Loading branch information
jcreekmore committed Aug 23, 2023
2 parents 0a50f0b + a2c1ad1 commit 3b855e1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,29 +240,29 @@ impl HeaderMap {

impl EncodeConfig {
/// Create a new encode config with default values.
pub fn new() -> Self {
Self::default()
pub const fn new() -> Self {
Self {
line_ending: LineEnding::CRLF,
line_wrap: LINE_WRAP,
}
}

/// Set the line ending to use for the encoding.
pub fn set_line_ending(mut self, line_ending: LineEnding) -> Self {
pub const fn set_line_ending(mut self, line_ending: LineEnding) -> Self {
self.line_ending = line_ending;
self
}

/// Set the line length to use for the encoding.
pub fn set_line_wrap(mut self, line_wrap: usize) -> Self {
pub const fn set_line_wrap(mut self, line_wrap: usize) -> Self {
self.line_wrap = line_wrap;
self
}
}

impl Default for EncodeConfig {
fn default() -> Self {
Self {
line_ending: LineEnding::CRLF,
line_wrap: LINE_WRAP,
}
Self::new()
}
}

Expand Down

0 comments on commit 3b855e1

Please sign in to comment.