mirror of
https://github.com/atuinsh/atuin.git
synced 2024-11-26 02:04:49 +01:00
Check before unwrapping in stats (#717)
Should fix the error @pdecat found!
This commit is contained in:
parent
5cb43772dc
commit
1f7d3a34e7
@ -26,9 +26,13 @@ pub struct Cmd {
|
||||
fn compute_stats(history: &[History], count: usize) -> Result<()> {
|
||||
let mut commands = HashMap::<&str, usize>::new();
|
||||
for i in history {
|
||||
*commands
|
||||
.entry(i.command.split_ascii_whitespace().next().unwrap())
|
||||
.or_default() += 1;
|
||||
let command = i.command.split_ascii_whitespace().next();
|
||||
|
||||
if command.is_none() {
|
||||
continue;
|
||||
}
|
||||
|
||||
*commands.entry(command.unwrap()).or_default() += 1;
|
||||
}
|
||||
let unique = commands.len();
|
||||
let mut top = commands.into_iter().collect::<Vec<_>>();
|
||||
|
Loading…
Reference in New Issue
Block a user