clippy fixes

This commit is contained in:
Robin Appelman 2024-07-28 17:16:06 +02:00
commit 04308e966b
4 changed files with 20 additions and 6 deletions

View file

@ -31,7 +31,7 @@ impl LogFile {
} }
} }
pub fn iter<'a>(&'a self) -> impl Iterator<Item = &'a str> + Send + 'a { pub fn iter(&self) -> impl Iterator<Item = &str> + Send + '_ {
self.content.lines() self.content.lines()
} }

View file

@ -41,7 +41,7 @@ fn main() -> MainResult {
let mut counts: HashMap<MatchResult, Vec<usize>> = HashMap::new(); let mut counts: HashMap<MatchResult, Vec<usize>> = HashMap::new();
let first = lines.next().unwrap(); let first = lines.next().unwrap();
let first_parsed: LogLine = match serde_json::from_str(&first) { let first_parsed: LogLine = match serde_json::from_str(first) {
Ok(first_parsed) => first_parsed, Ok(first_parsed) => first_parsed,
Err(e) => { Err(e) => {
eprintln!("Failed to parse the first line in the log: {:#}", e); eprintln!("Failed to parse the first line in the log: {:#}", e);
@ -65,7 +65,7 @@ fn main() -> MainResult {
.enumerate() .enumerate()
.par_bridge() .par_bridge()
.flat_map(|(index, line)| { .flat_map(|(index, line)| {
let mut parsed = serde_json::from_str::<LogLine>(&line).ok()?; let mut parsed = serde_json::from_str::<LogLine>(line).ok()?;
parsed.index = index; parsed.index = index;
Some(parsed) Some(parsed)
}) })

View file

@ -3,6 +3,7 @@ use itertools::Either;
use logsmash_data::{LogLevel, LoggingStatement, StatementList}; use logsmash_data::{LogLevel, LoggingStatement, StatementList};
use rayon::prelude::*; use rayon::prelude::*;
use regex::Regex; use regex::Regex;
use std::hash::{Hash, Hasher};
use std::iter::once; use std::iter::once;
pub struct LogMatch { pub struct LogMatch {
@ -91,7 +92,7 @@ impl Matcher {
} }
} }
#[derive(Debug, Clone, Eq, Hash)] #[derive(Debug, Clone, Eq)]
pub enum MatchResult { pub enum MatchResult {
Single(usize), Single(usize),
List(Vec<usize>), List(Vec<usize>),
@ -113,6 +114,19 @@ impl PartialEq for MatchResult {
} }
} }
impl Hash for MatchResult {
fn hash<H: Hasher>(&self, state: &mut H) {
match self {
MatchResult::Single(i) => i.hash(state),
MatchResult::List(list) => {
let mut list = list.clone();
list.sort();
list.hash(state);
}
}
}
}
impl MatchResult { impl MatchResult {
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
match self { match self {

View file

@ -180,12 +180,12 @@ impl<'a> UiState<'a> {
let line = &app.lines[state.lines[selected]]; let line = &app.lines[state.lines[selected]];
let raw = app.get_line(line.index).unwrap_or_default(); let raw = app.get_line(line.index).unwrap_or_default();
copy_osc(&raw); copy_osc(raw);
UiState::Logs(state) UiState::Logs(state)
} }
(UiState::Log(state), UiEvent::Copy) => { (UiState::Log(state), UiEvent::Copy) => {
let raw = app.get_line(state.log.index).unwrap_or_default(); let raw = app.get_line(state.log.index).unwrap_or_default();
copy_osc(&raw); copy_osc(raw);
UiState::Log(state) UiState::Log(state)
} }
( (