diff --git a/src/parse_styles.rs b/src/parse_styles.rs index 4eb62180..9d3ccdba 100644 --- a/src/parse_styles.rs +++ b/src/parse_styles.rs @@ -28,8 +28,15 @@ pub fn parse_styles(opt: &cli::Opt) -> HashMap { make_misc_styles(opt, &mut styles); let mut resolved_styles = resolve_style_references(styles, opt); - resolved_styles.get_mut("minus-emph-style").unwrap().is_emph = true; - resolved_styles.get_mut("plus-emph-style").unwrap().is_emph = true; + resolved_styles + .get_mut("minus-emph-style") + .unwrap_or_else(|| panic!("minus-emph-style not found in resolved styles")) + .is_emph = true; + + resolved_styles + .get_mut("plus-emph-style") + .unwrap_or_else(|| panic!("plus-emph-style not found in resolved styles")) + .is_emph = true; resolved_styles } @@ -114,7 +121,7 @@ fn parse_as_reference_to_git_config(style_string: &str, opt: &cli::Opt) -> Style } } -fn make_hunk_styles<'a>(opt: &'a cli::Opt, styles: &'a mut HashMap<&str, StyleReference>) { +fn make_hunk_styles(opt: &cli::Opt, styles: &mut HashMap<&str, StyleReference>) { let color_mode = opt.computed.color_mode; let true_color = opt.computed.true_color; let minus_style = style_from_str( diff --git a/src/style.rs b/src/style.rs index c52400c8..029cc395 100644 --- a/src/style.rs +++ b/src/style.rs @@ -307,17 +307,11 @@ impl fmt::Debug for AnsiTermStyleEqualityKey { } fn ansi_term_color_equality(a: Option, b: Option) -> bool { - match (a, b) { - (None, None) => true, - (None, Some(_)) => false, - (Some(_), None) => false, - (Some(a), Some(b)) => { - if a == b { - true - } else { - ansi_term_16_color_equality(a, b) || ansi_term_16_color_equality(b, a) - } + match a.zip(b) { + Some((a, b)) => { + a == b || ansi_term_16_color_equality(a, b) || ansi_term_16_color_equality(b, a) } + None => a.is_none() && b.is_none(), } }