clippy
This commit is contained in:
parent
92e8da6198
commit
dc53889dd5
@ -604,7 +604,6 @@ mod tests {
|
||||
do_extrema: false,
|
||||
do_roots: false,
|
||||
plot_width: pixel_width,
|
||||
..crate::egui_app::AppSettings::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,14 +5,12 @@ pub fn compile_hashmap(data: Vec<String>) -> Vec<(String, String)> {
|
||||
let start = std::time::Instant::now();
|
||||
println!("compile_hashmap");
|
||||
|
||||
let functions_processed: Vec<String> = data.iter().map(|e| e.to_string() + "(").collect();
|
||||
|
||||
let mut seen = HashSet::new();
|
||||
|
||||
let tuple_list_1: Vec<(String, String)> = functions_processed
|
||||
.into_iter()
|
||||
.map(|func| all_possible_splits(func, &mut seen))
|
||||
.flatten()
|
||||
let tuple_list_1: Vec<(String, String)> = data
|
||||
.iter()
|
||||
.map(|e| e.to_string() + "(")
|
||||
.flat_map(|func| all_possible_splits(func, &mut seen))
|
||||
.collect();
|
||||
|
||||
let keys: Vec<&String> = tuple_list_1.iter().map(|(a, _)| a).collect();
|
||||
@ -48,22 +46,20 @@ pub fn compile_hashmap(data: Vec<String>) -> Vec<(String, String)> {
|
||||
fn all_possible_splits(
|
||||
func: String, seen: &mut HashSet<(String, String)>,
|
||||
) -> Vec<(String, String)> {
|
||||
return (1..func.len())
|
||||
(1..func.len())
|
||||
.map(|i| {
|
||||
let (first, last) = func.split_at(i);
|
||||
return (first.to_string(), last.to_string());
|
||||
(first.to_string(), last.to_string())
|
||||
})
|
||||
.map(|(first, last)| {
|
||||
.flat_map(|(first, last)| {
|
||||
if seen.contains(&(first.clone(), last.clone())) {
|
||||
return None;
|
||||
}
|
||||
seen.insert((first.to_string(), last.to_string()));
|
||||
|
||||
return Some((first.to_string(), last.to_string()));
|
||||
Some((first, last))
|
||||
})
|
||||
.filter(|a| a.is_some())
|
||||
.map(|a| a.unwrap())
|
||||
.collect::<Vec<(String, String)>>();
|
||||
.collect::<Vec<(String, String)>>()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@ -6,7 +6,7 @@ use serde_json::Value as JsonValue;
|
||||
use rayon::prelude::*;
|
||||
|
||||
#[cfg(not(threading))]
|
||||
pub fn dyn_iter<'a, T>(input: &'a Vec<T>) -> impl Iterator<Item = &'a T>
|
||||
pub fn dyn_iter<'a, T>(input: &'a [T]) -> impl Iterator<Item = &'a T>
|
||||
where
|
||||
&'a [T]: IntoIterator,
|
||||
{
|
||||
@ -22,7 +22,7 @@ where
|
||||
}
|
||||
|
||||
#[cfg(not(threading))]
|
||||
pub fn dyn_mut_iter<'a, T>(input: &'a mut Vec<T>) -> impl Iterator<Item = &'a mut T>
|
||||
pub fn dyn_mut_iter<'a, T>(input: &'a mut [T]) -> impl Iterator<Item = &'a mut T>
|
||||
where
|
||||
&'a mut [T]: IntoIterator,
|
||||
{
|
||||
@ -252,7 +252,7 @@ pub fn decimal_round(x: f64, n: usize) -> f64 {
|
||||
/// `f_1` is f'(x) aka the derivative of f(x)
|
||||
/// The function returns a Vector of `x` values where roots occur
|
||||
pub fn newtons_method_helper(
|
||||
threshold: &f64, range: &std::ops::Range<f64>, data: &Vec<EguiValue>, f: &dyn Fn(f64) -> f64,
|
||||
threshold: &f64, range: &std::ops::Range<f64>, data: &[EguiValue], f: &dyn Fn(f64) -> f64,
|
||||
f_1: &dyn Fn(f64) -> f64,
|
||||
) -> Vec<f64> {
|
||||
data.iter()
|
||||
@ -277,7 +277,7 @@ fn newtons_method(
|
||||
let mut x2: f64;
|
||||
let mut fail: bool = false;
|
||||
loop {
|
||||
x2 = &x1 - (f(x1) / f_1(x1));
|
||||
x2 = x1 - (f(x1) / f_1(x1));
|
||||
if !range.contains(&x2) {
|
||||
fail = true;
|
||||
break;
|
||||
|
||||
@ -64,12 +64,7 @@ impl HintEnum<'static> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_multi(&self) -> bool {
|
||||
match self {
|
||||
HintEnum::Many(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
pub fn is_multi(&self) -> bool { matches!(self, HintEnum::Many(_)) }
|
||||
|
||||
pub fn ensure_many(&self) -> &[&str] {
|
||||
match self {
|
||||
@ -77,12 +72,7 @@ impl HintEnum<'static> {
|
||||
_ => panic!("ensure_many called on non-Many value"),
|
||||
}
|
||||
}
|
||||
pub fn is_some(&self) -> bool {
|
||||
match self {
|
||||
HintEnum::None => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
pub fn is_some(&self) -> bool { !matches!(self, HintEnum::None) }
|
||||
|
||||
pub fn is_none(&self) -> bool { !self.is_some() }
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user