Clippy Feedback

pull/24/head
Benedikt Terhechte 2 years ago
parent 9a35b99971
commit e8f9d9fdb5

@ -55,8 +55,8 @@ impl Entry {
fn as_row(&self, fields: &[Field]) -> QueryRow { fn as_row(&self, fields: &[Field]) -> QueryRow {
let mut row = QueryRow::new(); let mut row = QueryRow::new();
for field in fields { for field in fields {
let value = self.value(&field); let value = self.value(field);
let value_field = ValueField::new(&field, value); let value_field = ValueField::new(field, value);
row.insert(*field, value_field); row.insert(*field, value_field);
} }
row row
@ -66,6 +66,7 @@ impl Entry {
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
struct HashedValue(Value); struct HashedValue(Value);
#[allow(clippy::derive_hash_xor_eq)]
impl Hash for HashedValue { impl Hash for HashedValue {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) { fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
match &self.0 { match &self.0 {
@ -85,14 +86,15 @@ impl Hash for HashedValue {
pub struct FakeDatabase; pub struct FakeDatabase;
impl FakeDatabase { impl FakeDatabase {
#[allow(unused)]
pub fn total_item_count() -> usize { pub fn total_item_count() -> usize {
ENTRIES.len() ENTRIES.len()
} }
fn query_normal( fn query_normal(
&self, &self,
fields: &Vec<Field>, fields: &[Field],
filters: &Vec<Filter>, filters: &[Filter],
range: &Range<usize>, range: &Range<usize>,
) -> Vec<QueryResult> { ) -> Vec<QueryResult> {
let entries = self.filtered(filters); let entries = self.filtered(filters);
@ -103,7 +105,7 @@ impl FakeDatabase {
result result
} }
fn query_grouped(&self, filters: &Vec<Filter>, group_by: &Field) -> Vec<QueryResult> { fn query_grouped(&self, filters: &[Filter], group_by: &Field) -> Vec<QueryResult> {
let mut map = HashMap::<HashedValue, usize>::new(); let mut map = HashMap::<HashedValue, usize>::new();
for entry in self for entry in self
.filtered(filters) .filtered(filters)
@ -139,7 +141,7 @@ impl FakeDatabase {
result result
} }
fn filtered<'a>(&'a self, filters: &'a Vec<Filter>) -> impl Iterator<Item = &'a Entry> { fn filtered<'a>(&'a self, filters: &'a [Filter]) -> impl Iterator<Item = &'a Entry> {
ENTRIES.iter().filter(move |entry| { ENTRIES.iter().filter(move |entry| {
for filter in filters { for filter in filters {
// Go through all filters and escape early if they don't match // Go through all filters and escape early if they don't match

@ -1,4 +1,3 @@
use crossbeam_channel;
use eyre::Result; use eyre::Result;
use std::thread::JoinHandle; use std::thread::JoinHandle;

@ -42,6 +42,7 @@ pub struct Adapter {
} }
impl Adapter { impl Adapter {
#[allow(clippy::new_without_default)]
pub fn new() -> Self { pub fn new() -> Self {
let rw_lock = Arc::new(RwLock::default()); let rw_lock = Arc::new(RwLock::default());
// FIXME: Look up this warning. It looks like the clones are necessary? // FIXME: Look up this warning. It looks like the clones are necessary?

@ -200,5 +200,5 @@ fn random_filename() -> String {
use rand::Rng; use rand::Rng;
let number: u32 = rand::thread_rng().gen(); let number: u32 = rand::thread_rng().gen();
let filename = format!("{}.sqlite", number); let filename = format!("{}.sqlite", number);
return filename; filename
} }

@ -19,6 +19,7 @@ pub struct PostsackApp<Database: DatabaseLike> {
} }
impl<Database: DatabaseLike> PostsackApp<Database> { impl<Database: DatabaseLike> PostsackApp<Database> {
#[allow(clippy::new_without_default)]
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
pub fn new() -> Self { pub fn new() -> Self {
let state = StateUI::new(); let state = StateUI::new();

@ -15,9 +15,6 @@ use ps_core::{
Config, DatabaseLike, FormatType, Config, DatabaseLike, FormatType,
}; };
#[cfg(not(target_arch = "wasm32"))]
use ps_importer;
pub struct ImporterUI { pub struct ImporterUI {
/// The config for this configuration /// The config for this configuration
config: Config, config: Config,

@ -6,7 +6,6 @@
const SYSTEM_FONT: &[u8] = include_bytes!("../fonts/mac_regular.otf"); const SYSTEM_FONT: &[u8] = include_bytes!("../fonts/mac_regular.otf");
const SYSTEM_MONO_FONT: &[u8] = include_bytes!("../fonts/mac_mono.ttc"); const SYSTEM_MONO_FONT: &[u8] = include_bytes!("../fonts/mac_mono.ttc");
use cocoa;
use eframe::egui::{self, Color32, FontDefinitions, FontFamily, Stroke}; use eframe::egui::{self, Color32, FontDefinitions, FontFamily, Stroke};
use ps_core::eyre::{bail, Result}; use ps_core::eyre::{bail, Result};

@ -1,7 +1,7 @@
#![cfg(target_arch = "wasm32")] #![cfg(target_arch = "wasm32")]
use eframe::egui::{self, Color32}; use eframe::egui::{self, Color32};
use eyre::Result; use ps_core::eyre::Result;
use super::{PlatformColors, Theme}; use super::{PlatformColors, Theme};

@ -12,9 +12,6 @@ use eframe::{self, epi};
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
use eframe::{self, egui, epi}; use eframe::{self, egui, epi};
#[cfg(target_os = "macos")]
use image;
/// Pre-loaded textures /// Pre-loaded textures
pub struct Textures { pub struct Textures {
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]

@ -1,7 +1,6 @@
mod filesystem; mod filesystem;
mod mail; mod mail;
use shellexpand;
use std::{path::PathBuf, str::FromStr}; use std::{path::PathBuf, str::FromStr};
use super::{ImporterFormat, Result}; use super::{ImporterFormat, Result};

@ -4,7 +4,6 @@
//! (or aho corasick) //! (or aho corasick)
//! MBox parsing is also not particularly fast as it currently doesn't use parallelism //! MBox parsing is also not particularly fast as it currently doesn't use parallelism
use mbox_reader;
use ps_core::eyre::eyre; use ps_core::eyre::eyre;
use ps_core::tracing; use ps_core::tracing;
use rayon::prelude::*; use rayon::prelude::*;

Loading…
Cancel
Save