Skip to content

Commit

Permalink
feat(builder): Allow write! on StyledStr
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Mar 28, 2023
1 parent f19e33e commit 5ebcb4c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions clap_builder/src/builder/styled_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,20 @@ impl From<&'_ &'static str> for StyledStr {
}
}

impl std::fmt::Write for StyledStr {
#[inline]
fn write_str(&mut self, s: &str) -> Result<(), std::fmt::Error> {
self.0.push_str(s);
Ok(())
}

#[inline]
fn write_char(&mut self, c: char) -> Result<(), std::fmt::Error> {
self.0.push(c);
Ok(())
}
}

/// Color-unaware printing. Never uses coloring.
impl std::fmt::Display for StyledStr {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
Expand Down

0 comments on commit 5ebcb4c

Please sign in to comment.