mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 05:27:45 +00:00
Cleanup loop, run rustfmt
This commit is contained in:
parent
deb94cef7a
commit
8072e2092a
2 changed files with 16 additions and 11 deletions
|
@ -18,14 +18,14 @@ extern crate uucore;
|
||||||
mod ext_sorter;
|
mod ext_sorter;
|
||||||
mod numeric_str_cmp;
|
mod numeric_str_cmp;
|
||||||
|
|
||||||
use rayon::prelude::*;
|
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
|
use ext_sorter::{ExternalSorter, Sortable};
|
||||||
use fnv::FnvHasher;
|
use fnv::FnvHasher;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use numeric_str_cmp::{numeric_str_cmp, NumInfo, NumInfoParseSettings};
|
use numeric_str_cmp::{numeric_str_cmp, NumInfo, NumInfoParseSettings};
|
||||||
use ext_sorter::{ExternalSorter, Sortable};
|
|
||||||
use rand::distributions::Alphanumeric;
|
use rand::distributions::Alphanumeric;
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
|
use rayon::prelude::*;
|
||||||
use semver::Version;
|
use semver::Version;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
@ -271,16 +271,21 @@ impl Sortable for Line {
|
||||||
let result = {
|
let result = {
|
||||||
let mut line_joined = String::new();
|
let mut line_joined = String::new();
|
||||||
let mut selections_joined = SmallVec::new();
|
let mut selections_joined = SmallVec::new();
|
||||||
let p_iter = buf_reader.lines().peekable();
|
let mut p_iter = buf_reader.lines().peekable();
|
||||||
for line in p_iter {
|
while let Some(line) = p_iter.next() {
|
||||||
let mut deserialized_line: Line = serde_json::from_str(&line.unwrap()).unwrap();
|
let mut deserialized_line: Line =
|
||||||
line_joined = format!("{}\n{}\n", line_joined, deserialized_line.line);
|
serde_json::from_str(&line.as_ref().unwrap()).unwrap();
|
||||||
|
if let Some(_next_line) = p_iter.peek() {
|
||||||
|
line_joined = format!("{}\n{}\n", line_joined, deserialized_line.line)
|
||||||
|
} else {
|
||||||
|
line_joined = format!("{}\n{}", line_joined, deserialized_line.line)
|
||||||
|
}
|
||||||
// I think we've done our sorting already and these selctions are irrelevant?
|
// I think we've done our sorting already and these selctions are irrelevant?
|
||||||
// @miDeb what's your sense? Could we just return an empty vec?
|
// @miDeb what's your sense? Could we just return an empty vec?
|
||||||
selections_joined.append(&mut deserialized_line.selections);
|
selections_joined.append(&mut deserialized_line.selections);
|
||||||
}
|
}
|
||||||
Some(Line {
|
Some(Line {
|
||||||
line: line_joined.strip_suffix("\n").unwrap_or("").to_owned(),
|
line: line_joined,
|
||||||
selections: selections_joined,
|
selections: selections_joined,
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue