Apply strict linting to release builds #75

Merged
savanni merged 21 commits from clippy-linting into main 2023-10-05 17:01:49 +00:00
2 changed files with 8 additions and 15 deletions
Showing only changes of commit 10849687e3 - Show all commits

View File

@ -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"]

View File

@ -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<String, Error> {
let bundles = self.bundles.read().unwrap();
let result: Option<String> = self
.languages
.iter()
.map(|lang| {
let result: Option<String> = self.languages.iter().find_map(|lang| {
let bundle = bundles.get(lang)?;
self.tr_(bundle, msgid, args)
})
.filter(|v| v.is_some())
.map(|v| v.unwrap())
.next();
});
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)
}