Skip to content

Commit 40c36f6

Browse files
cakebakerxtqqczze
andauthored
uucore/build.rs: use functional style in fn (#12250)
for better readability Co-authored-by: xtqqczze <45661989+xtqqczze@users.noreply.github.com>
1 parent 873a7c7 commit 40c36f6

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

src/uucore/build.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,12 @@ fn embed_static_utility_locales(
274274
/// It always includes "en-US" to ensure that a fallback is available if the
275275
/// system locale's translation file is missing or if `LANG` is not set.
276276
fn get_locales_to_embed(env: Option<String>) -> (String, Option<String>) {
277-
let system_locale = env.and_then(|lang| {
278-
let locale = lang.split('.').next()?.replace('_', "-");
279-
if locale != "en-US" && !locale.is_empty() {
280-
Some(locale)
281-
} else {
282-
None
283-
}
284-
});
277+
let system_locale = env
278+
.as_deref()
279+
.and_then(|s| s.split('.').next())
280+
.map(|s| s.replace('_', "-"))
281+
.filter(|s| !s.is_empty() && s != "en-US");
282+
285283
("en-US".to_string(), system_locale)
286284
}
287285

0 commit comments

Comments
 (0)