clippy fixes

This commit is contained in:
Dmitry Belyaev 2022-08-25 15:49:12 +03:00
parent 5cf4cea9b0
commit 80382751df
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3

View File

@ -152,7 +152,7 @@ fn parse_file(file: impl io::Read) -> Result<json::JsonValue, Box<dyn std::error
ctx.last_keyword_type = ctx.cur_keyword_type; ctx.last_keyword_type = ctx.cur_keyword_type;
ctx.last_tag = ctx.cur_tag.clone(); ctx.last_tag = ctx.cur_tag.clone();
ctx.cur_keyword_type = Some(KeywordType::from(&pattern)); ctx.cur_keyword_type = Some(KeywordType::from(pattern));
ctx.cur_tag = pattern.replace(' ', "").replace(':', ""); ctx.cur_tag = pattern.replace(' ', "").replace(':', "");
// remember question id // remember question id
@ -218,14 +218,14 @@ fn parse_file(file: impl io::Read) -> Result<json::JsonValue, Box<dyn std::error
// split vector to a vector of [num] slices // split vector to a vector of [num] slices
trait SplitTo<T> { trait SplitTo<T> {
fn split_to<'a>(&'a self, num: usize) -> Vec<&'a [T]>; fn split_to(&self, num: usize) -> Vec<&[T]>;
} }
impl<T> SplitTo<T> for Vec<T> { impl<T> SplitTo<T> for Vec<T> {
fn split_to<'a>(&'a self, num: usize) -> Vec<&'a [T]> { fn split_to(&self, num: usize) -> Vec<&[T]> {
let part_len = self.len() / num; let part_len = self.len() / num;
let add_len = self.len() % num; let add_len = self.len() % num;
let mut result = Vec::<&'a [T]>::with_capacity(num); let mut result = Vec::<&[T]>::with_capacity(num);
if 0 == part_len { if 0 == part_len {
result.push(self); result.push(self);
@ -246,7 +246,7 @@ impl<T> SplitTo<T> for Vec<T> {
fn process_files(files: &&[PathBuf]) { fn process_files(files: &&[PathBuf]) {
if files.len() < 1 { if files.is_empty() {
return; return;
} }