clippy fixes
This commit is contained in:
parent
5cf4cea9b0
commit
80382751df
10
src/main.rs
10
src/main.rs
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user