@@ -155,7 +155,7 @@ impl<'a> Tokens<'a> {
155
155
} )
156
156
}
157
157
/// render a truncated line of tokens.
158
- fn render ( self , colors : & Vec < Color > , start : usize , end : usize , bold : bool ) -> String {
158
+ fn render ( self , colors : & [ Color ] , start : usize , end : usize , bold : bool ) -> String {
159
159
assert ! ( start <= end) ;
160
160
let mut width = end - start;
161
161
let mut colored_segment = String :: new ( ) ;
@@ -169,7 +169,7 @@ impl<'a> Tokens<'a> {
169
169
colored_segment. push ( chr) ;
170
170
}
171
171
Token :: Color ( col) => {
172
- add_colored_segment ( & mut whole_string, & colored_segment, color, bold) ;
172
+ add_colored_segment ( & mut whole_string, & colored_segment, * color, bold) ;
173
173
colored_segment = String :: new ( ) ;
174
174
color = colors. get ( col as usize ) . unwrap_or ( & Color :: White ) ;
175
175
}
@@ -180,7 +180,7 @@ impl<'a> Tokens<'a> {
180
180
} ;
181
181
} ) ;
182
182
183
- add_colored_segment ( & mut whole_string, & colored_segment, color, bold) ;
183
+ add_colored_segment ( & mut whole_string, & colored_segment, * color, bold) ;
184
184
( 0 ..width) . for_each ( |_| whole_string. push ( ' ' ) ) ;
185
185
whole_string
186
186
}
@@ -198,8 +198,8 @@ fn succeed_when<I>(predicate: impl FnOnce(I) -> bool) -> impl FnOnce(I) -> Optio
198
198
}
199
199
}
200
200
201
- fn add_colored_segment ( base : & mut String , segment : & String , color : & Color , bold : bool ) {
202
- let mut colored_segment = segment. color ( * color) ;
201
+ fn add_colored_segment ( base : & mut String , segment : & str , color : Color , bold : bool ) {
202
+ let mut colored_segment = segment. color ( color) ;
203
203
if bold {
204
204
colored_segment = colored_segment. bold ( ) ;
205
205
}
0 commit comments