From a7cc87f30fc45d9845a02a9971b0a594c031054d Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Sun, 5 Mar 2023 09:35:50 -0800 Subject: [PATCH] gdi.rs: Avoid non-idiomatic iterations over Option, they cause warnings --- wezterm-font/src/locator/gdi.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/wezterm-font/src/locator/gdi.rs b/wezterm-font/src/locator/gdi.rs index 949a29350..c72512aa5 100644 --- a/wezterm-font/src/locator/gdi.rs +++ b/wezterm-font/src/locator/gdi.rs @@ -79,11 +79,10 @@ fn extract_font_data( parse_and_collect_font_info(&source, &mut font_info, FontOrigin::Gdi)?; let matches = ParsedFont::best_match(attr, pixel_size, font_info); - for m in matches { - return Ok(m); + match matches { + Some(m) => Ok(m), + None => anyhow::bail!("No font matching {:?} in {:?}", attr, source), } - - anyhow::bail!("No font matching {:?} in {:?}", attr, source); } /// Convert a rust string to a windows wide string @@ -157,11 +156,10 @@ pub fn parse_log_font(log_font: &LOGFONTW, hdc: HDC) -> anyhow::Result<(ParsedFo parse_and_collect_font_info(&source, &mut font_info, FontOrigin::Gdi)?; let matches = ParsedFont::best_match(&attr, pixel_size, font_info); - for m in matches { - return Ok((m, point_size)); + match matches { + Some(m) => Ok((m, point_size)), + None => anyhow::bail!("No font matching {:?} in {:?}", attr, source), } - - anyhow::bail!("No font matching {:?} in {:?}", attr, source); } }