Resolve warnings in fluent-ergonomics
This commit is contained in:
parent
d441e19479
commit
10849687e3
|
@ -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"]
|
||||
|
|
|
@ -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 bundle = bundles.get(lang)?;
|
||||
self.tr_(bundle, msgid, args)
|
||||
})
|
||||
.filter(|v| v.is_some())
|
||||
.map(|v| v.unwrap())
|
||||
.next();
|
||||
let result: Option<String> = 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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue