fix: add pedantic lints
This commit is contained in:
parent
81280200f7
commit
cbeb14f3fd
41 changed files with 520 additions and 447 deletions
|
|
@ -35,14 +35,18 @@ pub fn generate_dictionary() {
|
|||
|
||||
let code_head = r#"// This file is automatically generated. DO NOT EDIT.
|
||||
// See codegen/gen_dictionary.rs for the generation code.
|
||||
#![allow(clippy::unreadable_literal)]
|
||||
|
||||
//! The dictionary contains the information required to parse dates and numbers
|
||||
//! in all supported languages.
|
||||
|
||||
use crate::{
|
||||
model::AlbumType,
|
||||
param::Language,
|
||||
util::timeago::{DateCmp, TaToken, TimeUnit},
|
||||
};
|
||||
|
||||
/// The dictionary contains the information required to parse dates and numbers
|
||||
/// in all supported languages.
|
||||
/// Dictionary entry containing language-specific parsing information
|
||||
pub(crate) struct Entry {
|
||||
/// Tokens for parsing timeago strings.
|
||||
///
|
||||
|
|
@ -90,11 +94,11 @@ pub(crate) fn entry(lang: Language) -> Entry {
|
|||
"#
|
||||
.to_owned();
|
||||
|
||||
dict.iter().for_each(|(lang, entry)| {
|
||||
for (lang, entry) in &dict {
|
||||
// Match selector
|
||||
let mut selector = format!("Language::{lang:?}");
|
||||
entry.equivalent.iter().for_each(|eq| {
|
||||
let _ = write!(selector, " | Language::{eq:?}");
|
||||
write!(selector, " | Language::{eq:?}").unwrap();
|
||||
});
|
||||
|
||||
// Timeago tokens
|
||||
|
|
@ -132,7 +136,7 @@ pub(crate) fn entry(lang: Language) -> Entry {
|
|||
// Date order
|
||||
let mut date_order = "&[".to_owned();
|
||||
entry.date_order.chars().for_each(|c| {
|
||||
let _ = write!(date_order, "DateCmp::{c}, ");
|
||||
write!(date_order, "DateCmp::{c}, ").unwrap();
|
||||
});
|
||||
date_order = date_order.trim_end_matches([' ', ',']).to_owned() + "]";
|
||||
|
||||
|
|
@ -154,16 +158,31 @@ pub(crate) fn entry(lang: Language) -> Entry {
|
|||
album_types.entry(txt, &format!("AlbumType::{album_type:?}"));
|
||||
});
|
||||
|
||||
let code_ta_tokens = &ta_tokens.build().to_string().replace('\n', "\n ");
|
||||
let code_ta_nd_tokens = &ta_nd_tokens.build().to_string().replace('\n', "\n ");
|
||||
let code_ta_tokens = &ta_tokens
|
||||
.build()
|
||||
.to_string()
|
||||
.replace('\n', "\n ");
|
||||
let code_ta_nd_tokens = &ta_nd_tokens
|
||||
.build()
|
||||
.to_string()
|
||||
.replace('\n', "\n ");
|
||||
let code_months = &months.build().to_string().replace('\n', "\n ");
|
||||
let code_number_tokens = &number_tokens.build().to_string().replace('\n', "\n ");
|
||||
let code_number_nd_tokens = &number_nd_tokens.build().to_string().replace('\n', "\n ");
|
||||
let code_album_types = &album_types.build().to_string().replace('\n', "\n ");
|
||||
let code_number_tokens = &number_tokens
|
||||
.build()
|
||||
.to_string()
|
||||
.replace('\n', "\n ");
|
||||
let code_number_nd_tokens = &number_nd_tokens
|
||||
.build()
|
||||
.to_string()
|
||||
.replace('\n', "\n ");
|
||||
let code_album_types = &album_types
|
||||
.build()
|
||||
.to_string()
|
||||
.replace('\n', "\n ");
|
||||
|
||||
write!(code_timeago_tokens, "{} => Entry {{\n timeago_tokens: {},\n date_order: {},\n months: {},\n timeago_nd_tokens: {},\n comma_decimal: {:?},\n number_tokens: {},\n number_nd_tokens: {},\n album_types: {},\n }},\n ",
|
||||
selector, code_ta_tokens, date_order, code_months, code_ta_nd_tokens, entry.comma_decimal, code_number_tokens, code_number_nd_tokens, code_album_types).unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
code_timeago_tokens = code_timeago_tokens.trim_end().to_owned() + "\n }\n}\n";
|
||||
|
||||
|
|
|
|||
Reference in a new issue