From 598e9a01f8a0919e5fb60dab839fd2070feabdfd Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Wed, 4 Oct 2023 16:25:29 -0400 Subject: [PATCH] Resolve warnings in fluent-ergonomics --- fluent-ergonomics/Cargo.toml | 1 - fluent-ergonomics/src/lib.rs | 22 ++++++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/fluent-ergonomics/Cargo.toml b/fluent-ergonomics/Cargo.toml index edddd75..f23728b 100644 --- a/fluent-ergonomics/Cargo.toml +++ b/fluent-ergonomics/Cargo.toml @@ -5,7 +5,6 @@ edition = "2018" version = "0.2.0" description = "An ergonomics wrapper around Fluent-RS" license = "GPL-3.0-only" -license-file = "../COPYING" homepage = "https://github.com/luminescent-dreams/fluent-ergonomics" repository = "https://github.com/luminescent-dreams/fluent-ergonomics" categories = ["internationalization"] diff --git a/fluent-ergonomics/src/lib.rs b/fluent-ergonomics/src/lib.rs index d6e6bcf..06feb80 100644 --- a/fluent-ergonomics/src/lib.rs +++ b/fluent-ergonomics/src/lib.rs @@ -171,14 +171,14 @@ impl FluentErgo { match entry { Entry::Occupied(mut e) => { let bundle = e.get_mut(); - bundle.add_resource(res).map_err(|err| Error::from(err)) + bundle.add_resource(res).map_err(Error::from) } Entry::Vacant(e) => { let mut bundle: FluentBundle< FluentResource, intl_memoizer::concurrent::IntlLangMemoizer, > = FluentBundle::new_concurrent(vec![lang]); - bundle.add_resource(res).map_err(|err| Error::from(err))?; + bundle.add_resource(res).map_err(Error::from)?; e.insert(bundle); Ok(()) } @@ -248,16 +248,10 @@ impl FluentErgo { /// pub fn tr(&self, msgid: &str, args: Option<&FluentArgs>) -> Result { let bundles = self.bundles.read().unwrap(); - let result: Option = self - .languages - .iter() - .map(|lang| { - let bundle = bundles.get(lang)?; - self.tr_(bundle, msgid, args) - }) - .filter(|v| v.is_some()) - .map(|v| v.unwrap()) - .next(); + let result: Option = self.languages.iter().find_map(|lang| { + let bundle = bundles.get(lang)?; + self.tr_(bundle, msgid, args) + }); match result { Some(r) => Ok(r), @@ -276,8 +270,8 @@ impl FluentErgo { let res = match pattern { None => None, Some(p) => { - let res = bundle.format_pattern(&p, args, &mut errors); - if errors.len() > 0 { + let res = bundle.format_pattern(p, args, &mut errors); + if !errors.is_empty() { println!("Errors in formatting: {:?}", errors) }