mirror of
https://github.com/icewind1991/zox
synced 2026-06-04 02:44:06 +02:00
bumb dependencies
This commit is contained in:
parent
fcb489462f
commit
9aa8e2d238
4 changed files with 148 additions and 92 deletions
20
src/main.rs
20
src/main.rs
|
|
@ -1,6 +1,7 @@
|
|||
use main_error::MainError;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cmp::Ordering;
|
||||
use std::convert::Infallible;
|
||||
use std::io::{stdout, Write};
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
|
|
@ -41,7 +42,11 @@ impl Args {
|
|||
SortBy::Frecent
|
||||
},
|
||||
list: args.contains("-l"),
|
||||
filter: args.free().unwrap_or_default(),
|
||||
filter: args
|
||||
.free_from_fn::<_, Infallible>(|free| {
|
||||
Ok(free.split(' ').map(str::to_ascii_lowercase).collect())
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -75,6 +80,16 @@ impl History {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_history_match() {
|
||||
assert!(History {
|
||||
path: "/foo/bar".into(),
|
||||
time: 0,
|
||||
rank: 0.0,
|
||||
}
|
||||
.matches(&["foo".into(), "bar".into()]))
|
||||
}
|
||||
|
||||
fn now() -> u64 {
|
||||
let start = SystemTime::now();
|
||||
start
|
||||
|
|
@ -170,8 +185,7 @@ fn main() -> Result<(), MainError> {
|
|||
}
|
||||
|
||||
if let Ok(history) = history_result {
|
||||
let filter: Vec<String> = args.filter.iter().map(|s| s.to_lowercase()).collect();
|
||||
let matches = history.filter(|item| item.matches(&filter));
|
||||
let matches = history.filter(|item| item.matches(&args.filter));
|
||||
|
||||
let mut matches: Vec<History> = matches.collect();
|
||||
matches.sort_by(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue