From 720c557faac51345b926a7df1eaef5fd4f402035 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Tue, 12 May 2026 11:06:17 +0200 Subject: [PATCH] uucore/build.rs: use functional style in fn for better readability Co-authored-by: xtqqczze <45661989+xtqqczze@users.noreply.github.com> --- src/uucore/build.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/uucore/build.rs b/src/uucore/build.rs index 0a59b17017..50f66d8db3 100644 --- a/src/uucore/build.rs +++ b/src/uucore/build.rs @@ -274,14 +274,12 @@ fn embed_static_utility_locales( /// It always includes "en-US" to ensure that a fallback is available if the /// system locale's translation file is missing or if `LANG` is not set. fn get_locales_to_embed(env: Option) -> (String, Option) { - let system_locale = env.and_then(|lang| { - let locale = lang.split('.').next()?.replace('_', "-"); - if locale != "en-US" && !locale.is_empty() { - Some(locale) - } else { - None - } - }); + let system_locale = env + .as_deref() + .and_then(|s| s.split('.').next()) + .map(|s| s.replace('_', "-")) + .filter(|s| !s.is_empty() && s != "en-US"); + ("en-US".to_string(), system_locale) }