on master help sign in
Replace iterator with string starts_with and ends_with
2b9d25dEthan P
src/printer.rs+2−3
@@ -367,10 +367,9 @@ impl<'a> Printer for InteractivePrinter<'a> {
367 match chunk {
367 match chunk {
368 // ANSI escape passthrough.
368 // ANSI escape passthrough.
369 (text, true) => {
369 (text, true) => {
370− let is_ansi_csi =
370+ let is_ansi_csi = text.starts_with("\x1B[");
371− text.chars().skip(1).nth(0).map_or(false, |c| c == '[');
372
371
373− if is_ansi_csi && text.chars().last().map_or(false, |c| c == 'm') {
372+ if is_ansi_csi && text.ends_with('m') {
374 // It's an ANSI SGR sequence.
373 // It's an ANSI SGR sequence.
375 // We should be mostly safe to just append these together.
374 // We should be mostly safe to just append these together.
376 ansi_prefix.push_str(text);
375 ansi_prefix.push_str(text);