Skip to content

Commit

Permalink
run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ElenaKrippner committed Dec 11, 2023
1 parent ed22c17 commit 9d064a9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
22 changes: 11 additions & 11 deletions commons/src/config/locale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ pub mod serde {

pub mod multiple {
use super::*;
use std::collections::HashSet;
use crate::config::log_id::ConfigWarning;
use logid::log;
use serde::de::{SeqAccess, Visitor};
use serde::ser::SerializeSeq;
use crate::config::log_id::ConfigWarning;
use std::collections::HashSet;

pub fn serialize<S>(locales: &HashSet<Locale>, serializer: S) -> Result<S::Ok, S::Error>
where
Expand Down Expand Up @@ -70,8 +70,8 @@ pub mod serde {
formatter.write_str("Sequence of locales.")
}
fn visit_seq<M>(self, mut access: M) -> Result<Self::Value, M::Error>
where
M: SeqAccess<'de>,
where
M: SeqAccess<'de>,
{
let mut set = HashSet::with_capacity(access.size_hint().unwrap_or(0));
while let Some(value) = access.next_element::<String>()? {
Expand Down Expand Up @@ -128,10 +128,10 @@ pub mod serde {

pub mod hashmap {
use super::*;
use std::collections::HashMap;
use std::path::PathBuf;
use serde::de::{MapAccess, Visitor};
use serde::ser::SerializeMap;
use std::collections::HashMap;
use std::path::PathBuf;

pub fn serialize<S>(
locales_map: &HashMap<Locale, PathBuf>,
Expand All @@ -142,7 +142,7 @@ pub mod serde {
{
let mut map = serializer.serialize_map(Some(locales_map.len()))?;
for (locale, path) in locales_map {
map.serialize_entry(&locale.to_string(),path)?;
map.serialize_entry(&locale.to_string(), path)?;
}
map.end()
}
Expand All @@ -155,8 +155,8 @@ pub mod serde {
//
// although it may also be generic over the output types T.
pub fn deserialize<'de, D>(deserializer: D) -> Result<HashMap<Locale, PathBuf>, D::Error>
where
D: Deserializer<'de>,
where
D: Deserializer<'de>,
{
deserializer.deserialize_map(LocaleMapVisitor {})
}
Expand All @@ -167,8 +167,8 @@ pub mod serde {
formatter.write_str("Map with locale as key and file path as value.")
}
fn visit_map<M>(self, mut access: M) -> Result<Self::Value, M::Error>
where
M: MapAccess<'de>,
where
M: MapAccess<'de>,
{
let mut map = HashMap::with_capacity(access.size_hint().unwrap_or(0));
while let Some((key, value)) = access.next_entry::<String, PathBuf>()? {
Expand Down
13 changes: 6 additions & 7 deletions commons/src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{collections::HashSet, path::PathBuf};
use std::error::Error;
use std::str::FromStr;
use std::{collections::HashSet, path::PathBuf};

use clap::{Args, Parser};
use logid::{err, log};
Expand All @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
use self::{log_id::ConfigErr, output::Output, preamble::Preamble};

pub use icu_locid;
use icu_locid::{Locale, locale};
use icu_locid::{locale, Locale};

pub mod locale;
pub mod log_id;
Expand Down Expand Up @@ -118,8 +118,9 @@ where
Ok(HashSet::from_iter(entries?))
}

fn parse_locale_path_buf(s: &str) -> Result<(Locale, PathBuf), Box<dyn Error + Send + Sync + 'static>>
{
fn parse_locale_path_buf(
s: &str,
) -> Result<(Locale, PathBuf), Box<dyn Error + Send + Sync + 'static>> {
if s.is_empty() {
return Ok((locale!("en"), PathBuf::from_str("invalid path").unwrap()));
}
Expand All @@ -136,9 +137,7 @@ fn parse_locale_path_buf(s: &str) -> Result<(Locale, PathBuf), Box<dyn Error + S
);
}
};
let path_buf: PathBuf = s[pos + 1..]
.parse()
.unwrap();
let path_buf: PathBuf = s[pos + 1..].parse().unwrap();
Ok((locale, path_buf))
}

Expand Down
9 changes: 5 additions & 4 deletions commons/src/config/preamble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use logid::err;
use serde::{Deserialize, Serialize};

use super::{
locale, log_id::ConfigErr, parse_to_hashset, parse_locale_path_buf, ConfigFns,
ReplaceIfNone,
locale, log_id::ConfigErr, parse_locale_path_buf, parse_to_hashset, ConfigFns, ReplaceIfNone,
};

#[derive(Args, Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
Expand Down Expand Up @@ -125,10 +124,12 @@ impl ConfigFns for Citedata {
self.style.replace_none(other.style);
self.references.extend(other.references);
for locale_path_buf in self.csl_locales.clone() {
self.citation_locales.insert(locale_path_buf.0, locale_path_buf.1);
self.citation_locales
.insert(locale_path_buf.0, locale_path_buf.1);
}
for locale_path_buf in other.csl_locales.clone() {
self.citation_locales.insert(locale_path_buf.0, locale_path_buf.1);
self.citation_locales
.insert(locale_path_buf.0, locale_path_buf.1);
}
self.citation_locales.extend(other.citation_locales);
}
Expand Down

0 comments on commit 9d064a9

Please sign in to comment.