huge clippy

This commit is contained in:
Emilia Allison 2024-02-10 22:00:39 -05:00
parent 338a7b98c7
commit a8b72c0a7a
Signed by: emilia
GPG Key ID: 05D5D1107E5100A1
10 changed files with 41 additions and 42 deletions

View File

@ -1,29 +1,27 @@
use std::collections::HashSet;
use std::str::FromStr;
use js_sys::Array;
use lazy_static::lazy_static;
use regex::Regex;
use wasm_bindgen::{prelude::*, JsCast, JsValue};
use wasm_bindgen::{prelude::*, JsCast};
use web_sys::{
Blob, FileReader, HtmlAnchorElement, HtmlButtonElement, HtmlDialogElement, HtmlElement,
HtmlFormElement, HtmlInputElement, HtmlOptionElement, HtmlSelectElement, Url,
FileReader, HtmlButtonElement, HtmlDialogElement,
HtmlFormElement, HtmlInputElement, HtmlOptionElement, HtmlSelectElement,
};
use yew::prelude::*;
use yewdux::prelude::*;
use crate::components::states::{CurrentTransfer, MainState};
use crate::components::states::{MainState};
use crate::components::transfer_menu::letters_to_num;
use crate::data::transfer::Transfer;
use crate::data::transfer_region::{Region, TransferRegion};
use crate::data::csv::{state_to_csv, TransferRecord};
use crate::data::csv::{TransferRecord};
use super::main_window_callbacks::create_close_button;
type NoParamsCallback = Box<dyn Fn(()) -> ()>;
pub fn import_transfer_csv_input_callback(
main_dispatch: Dispatch<MainState>,
modal: HtmlDialogElement,
@ -108,7 +106,7 @@ pub fn import_transfer_csv_onload_callback(
) -> Closure<dyn FnMut(Event)> {
Closure::<dyn FnMut(_)>::new(move |_: Event| {
if let Some(value) = &file_reader.result().ok().and_then(|v| v.as_string()) {
let (header, data) = value.split_at(value.find("\n").unwrap());
let (header, data) = value.split_at(value.find('\n').unwrap());
let modified: String = header.to_lowercase() + data;
log::info!("{}", modified);
let mut rdr = csv::Reader::from_reader(value.as_bytes());

View File

@ -1,26 +1,26 @@
#![allow(non_snake_case)]
use std::collections::HashSet;
use js_sys::Array;
use lazy_static::lazy_static;
use regex::Regex;
use wasm_bindgen::{prelude::*, JsCast, JsValue};
use web_sys::{
Blob, FileReader, HtmlAnchorElement, HtmlButtonElement, HtmlDialogElement, HtmlElement,
HtmlFormElement, HtmlInputElement, HtmlOptionElement, HtmlSelectElement, Url,
Blob, HtmlAnchorElement, HtmlDialogElement, HtmlElement,
HtmlFormElement, HtmlInputElement, Url,
};
use yew::prelude::*;
use yewdux::prelude::*;
use crate::components::states::{CurrentTransfer, MainState};
use crate::components::transfer_menu::letters_to_num;
use crate::data::transfer::Transfer;
use crate::data::transfer_region::{Region, TransferRegion};
use crate::data::csv::{state_to_csv, TransferRecord};
type NoParamsCallback = Box<dyn Fn(()) -> ()>;
use crate::data::csv::{state_to_csv};
type NoParamsCallback = Box<dyn Fn(())>;
pub fn create_close_button(close: &Closure<dyn FnMut(Event)>) -> HtmlElement {
let document = web_sys::window().unwrap().document().unwrap();
@ -33,7 +33,7 @@ pub fn create_close_button(close: &Closure<dyn FnMut(Event)>) -> HtmlElement {
close_button.set_class_name("close_button");
close_button.set_onclick(Some(close.as_ref().unchecked_ref()));
return close_button;
close_button
}
pub fn toggle_in_transfer_hashes_callback(

View File

@ -8,7 +8,7 @@ use yewdux::prelude::*;
use crate::components::states::{CurrentTransfer, MainState};
use crate::data::transfer_region::Region;
type NoParamsCallback = Box<dyn Fn(()) -> ()>;
type NoParamsCallback = Box<dyn Fn(())>;
pub fn open_plate_info_callback(
plate_menu_id: UseStateHandle<Option<Uuid>>,

View File

@ -1,8 +1,8 @@
#![allow(non_snake_case)]
use js_sys::Array;
use wasm_bindgen::{prelude::*, JsCast, JsValue};
use web_sys::{Blob, HtmlAnchorElement, HtmlDialogElement, HtmlFormElement, HtmlInputElement, Url};
use yew::prelude::*;
use yewdux::prelude::*;

View File

@ -13,7 +13,7 @@ use crate::data::transfer_region::Region;
use crate::components::plates::util::Palettes;
const PALETTE: super::util::ColorPalette = Palettes::RAINBOW;
use super::super::transfer_menu::{num_to_letters, RegionDisplay};
use super::super::transfer_menu::{num_to_letters};
use super::plate_data::*;
use super::plate_callbacks;

View File

@ -1,4 +1,4 @@
use serde::{Serialize, Deserialize};
use yew::prelude::*;
use crate::data::plate_instances::PlateInstance;

View File

@ -2,9 +2,9 @@
// https://iquilezles.org/articles/palettes/
// http://dev.thi.ng/gradients/
use rand::prelude::*;
use rand::rngs::SmallRng;
use lazy_static::lazy_static;
#[derive(Clone, Copy, PartialEq, Debug)]
pub struct ColorPalette {
@ -41,17 +41,17 @@ impl ColorPalette {
// self.get(r.gen_range(0.0..1.0f64))
// }
pub fn get_ordered(&self, t: uuid::Uuid, ordered_uuids: &Vec<uuid::Uuid>)
pub fn get_ordered(&self, t: uuid::Uuid, ordered_uuids: &[uuid::Uuid])
-> [f64; 3] {
let index = ordered_uuids.iter().position(|&x| x == t).expect("uuid must be in list of uuids") + 1;
return self.get(Self::space_evenly(index))
self.get(Self::space_evenly(index))
}
fn space_evenly(x: usize) -> f64 {
let e: usize = (x.ilog2() + 1) as usize;
let d: usize = (2usize.pow(e as u32)) as usize;
let d: usize = 2usize.pow(e as u32);
let n: usize = (2*x + 1) % d;
return (n as f64) / (d as f64);
(n as f64) / (d as f64)
}
}

View File

@ -205,7 +205,7 @@ impl TryFrom<&str> for RegionDisplay {
lazy_static! {
static ref REGION_REGEX: Regex = Regex::new(r"([A-Z]+)(\d+):([A-Z]+)(\d+)").unwrap();
}
if let Some(captures) = REGION_REGEX.captures(&value) {
if let Some(captures) = REGION_REGEX.captures(value) {
if captures.len() != 5 {
return Err("Not enough capture groups");
}

View File

@ -40,7 +40,7 @@ pub fn state_to_csv(state: &MainState) -> Result<String, Box<dyn Error>> {
&dest_barcode.name,
))
}
return records_to_csv(records);
records_to_csv(records)
}
fn transfer_to_records(

View File

@ -1,7 +1,5 @@
use serde::{Deserialize, Serialize};
use crate::components::transfer_menu::RegionDisplay;
use super::plate::Plate;
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
@ -32,8 +30,11 @@ impl TryFrom<Region> for ((u8, u8), (u8, u8)) {
}
}
}
type Corner = (u8, u8);
type Rectangle = (Corner, Corner);
impl Region {
pub fn new_custom(transfers: &Vec<((u8, u8), (u8, u8))>) -> Self {
pub fn new_custom(transfers: &Vec<Rectangle>) -> Self {
let mut src_pts: Vec<(u8, u8)> = Vec::with_capacity(transfers.len());
let mut dest_pts: Vec<(u8, u8)> = Vec::with_capacity(transfers.len());
@ -77,7 +78,7 @@ impl TransferRegion {
match &self.source_region {
Region::Rect(c1, c2) => {
let mut wells = Vec::<(u8, u8)>::new();
let (ul, br) = standardize_rectangle(&c1, &c2);
let (ul, br) = standardize_rectangle(c1, c2);
let (interleave_i, interleave_j) = self.interleave_source;
// NOTE: This will panic if either is 0!
// We'll reassign these values (still not mutable) just in case.
@ -174,8 +175,8 @@ impl TransferRegion {
Region::Rect(c1, c2) => {
Box::new(move |(i, j)| {
if source_wells.contains(&(i, j)) {
let possible_destination_wells = create_dense_rectangle(&c1, &c2);
let (d_ul, d_br) = standardize_rectangle(&c1, &c2);
let possible_destination_wells = create_dense_rectangle(c1, c2);
let (d_ul, d_br) = standardize_rectangle(c1, c2);
let (s_ul, s_br) =
standardize_rectangle(&source_corners.0, &source_corners.1);
let s_dims = (