Skip to content

Commit 133f306

Browse files
committed
refactor(roff): Simplify the code
1 parent 10bf01b commit 133f306

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

crates/anstyle-roff/src/lib.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,15 @@ mod control_requests {
3939
pub fn to_roff(styled_text: &str) -> Roff {
4040
let mut doc = Roff::new();
4141
for styled in styled_str::styled_stream(styled_text) {
42-
set_color(
43-
(&styled.style.get_fg_color(), &styled.style.get_bg_color()),
42+
add_color_to_roff(
4443
&mut doc,
44+
control_requests::FOREGROUND,
45+
&styled.style.get_fg_color(),
46+
);
47+
add_color_to_roff(
48+
&mut doc,
49+
control_requests::BACKGROUND,
50+
&styled.style.get_bg_color(),
4551
);
4652
set_effects_and_text(&styled, &mut doc);
4753
}
@@ -93,13 +99,6 @@ fn is_bright(fg_color: &Color) -> bool {
9399
}
94100
}
95101

96-
type ColorSet<'a> = (&'a Option<Color>, &'a Option<Color>);
97-
98-
fn set_color(colors: ColorSet<'_>, doc: &mut Roff) {
99-
add_color_to_roff(doc, control_requests::FOREGROUND, colors.0);
100-
add_color_to_roff(doc, control_requests::BACKGROUND, colors.1);
101-
}
102-
103102
fn add_color_to_roff(doc: &mut Roff, control_request: &str, color: &Option<Color>) {
104103
match color {
105104
Some(Color::Rgb(c)) => {

0 commit comments

Comments
 (0)