cleanup
This commit is contained in:
parent
5e5dd0f7a6
commit
243135b3dc
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
@ -43,7 +43,8 @@ jobs:
|
|||||||
version: latest
|
version: latest
|
||||||
- run: cargo test-all-features
|
- run: cargo test-all-features
|
||||||
|
|
||||||
# - name: Test Parsing
|
- name: Test Parsing
|
||||||
# uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
# with:
|
with:
|
||||||
# command: test --package parsing
|
command: test
|
||||||
|
args: --package parsing
|
||||||
|
|||||||
14
Cargo.lock
generated
14
Cargo.lock
generated
@ -663,7 +663,7 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "eframe"
|
name = "eframe"
|
||||||
version = "0.18.0"
|
version = "0.18.0"
|
||||||
source = "git+https://github.com/Titaniumtown/egui.git#f77c972b1405666b9f0250c44d7b488ac40e1f04"
|
source = "git+https://github.com/Titaniumtown/egui.git#ffef46110abfe2d0c9891d3e457eccb1b8a75842"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"egui",
|
"egui",
|
||||||
@ -683,7 +683,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "egui"
|
name = "egui"
|
||||||
version = "0.18.1"
|
version = "0.18.1"
|
||||||
source = "git+https://github.com/Titaniumtown/egui.git#f77c972b1405666b9f0250c44d7b488ac40e1f04"
|
source = "git+https://github.com/Titaniumtown/egui.git#ffef46110abfe2d0c9891d3e457eccb1b8a75842"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ahash",
|
"ahash",
|
||||||
"epaint",
|
"epaint",
|
||||||
@ -694,7 +694,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "egui-winit"
|
name = "egui-winit"
|
||||||
version = "0.18.0"
|
version = "0.18.0"
|
||||||
source = "git+https://github.com/Titaniumtown/egui.git#f77c972b1405666b9f0250c44d7b488ac40e1f04"
|
source = "git+https://github.com/Titaniumtown/egui.git#ffef46110abfe2d0c9891d3e457eccb1b8a75842"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arboard",
|
"arboard",
|
||||||
"egui",
|
"egui",
|
||||||
@ -707,7 +707,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "egui_glow"
|
name = "egui_glow"
|
||||||
version = "0.18.0"
|
version = "0.18.0"
|
||||||
source = "git+https://github.com/Titaniumtown/egui.git#f77c972b1405666b9f0250c44d7b488ac40e1f04"
|
source = "git+https://github.com/Titaniumtown/egui.git#ffef46110abfe2d0c9891d3e457eccb1b8a75842"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"egui",
|
"egui",
|
||||||
@ -727,7 +727,7 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "emath"
|
name = "emath"
|
||||||
version = "0.18.0"
|
version = "0.18.0"
|
||||||
source = "git+https://github.com/Titaniumtown/egui.git#f77c972b1405666b9f0250c44d7b488ac40e1f04"
|
source = "git+https://github.com/Titaniumtown/egui.git#ffef46110abfe2d0c9891d3e457eccb1b8a75842"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
]
|
]
|
||||||
@ -735,7 +735,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "epaint"
|
name = "epaint"
|
||||||
version = "0.18.1"
|
version = "0.18.1"
|
||||||
source = "git+https://github.com/Titaniumtown/egui.git#f77c972b1405666b9f0250c44d7b488ac40e1f04"
|
source = "git+https://github.com/Titaniumtown/egui.git#ffef46110abfe2d0c9891d3e457eccb1b8a75842"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ab_glyph",
|
"ab_glyph",
|
||||||
"ahash",
|
"ahash",
|
||||||
@ -2832,8 +2832,6 @@ dependencies = [
|
|||||||
"itertools",
|
"itertools",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"parsing",
|
"parsing",
|
||||||
"phf",
|
|
||||||
"phf_codegen",
|
|
||||||
"rayon",
|
"rayon",
|
||||||
"ruzstd",
|
"ruzstd",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
|||||||
@ -51,7 +51,6 @@ serde_json = "1.0"
|
|||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
itertools = "0.10"
|
itertools = "0.10"
|
||||||
static_assertions = "1.1"
|
static_assertions = "1.1"
|
||||||
phf = "0.10"
|
|
||||||
uuid = { version = "1", features = ["v4", "fast-rng", "js"] }
|
uuid = { version = "1", features = ["v4", "fast-rng", "js"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
@ -60,8 +59,6 @@ benchmarks = { path = "./benchmarks" }
|
|||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
shadow-rs = "0.11"
|
shadow-rs = "0.11"
|
||||||
command-run = "1.1"
|
command-run = "1.1"
|
||||||
phf_codegen = "0.10"
|
|
||||||
itertools = "0.10"
|
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
instant = "0.1"
|
instant = "0.1"
|
||||||
|
|||||||
@ -30,9 +30,12 @@ pub fn compile_hashmap(data: Vec<String>) -> Vec<(String, String)> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
seen_3.insert(key.clone());
|
seen_3.insert(key.clone());
|
||||||
if keys.iter().filter(|a| a == &&key).count() == 1 {
|
|
||||||
|
let count_keys = keys.iter().filter(|a| a == &&key).count();
|
||||||
|
|
||||||
|
if count_keys == 1 {
|
||||||
output.push((key.clone(), format!(r#"Hint::Single("{}")"#, value)));
|
output.push((key.clone(), format!(r#"Hint::Single("{}")"#, value)));
|
||||||
} else {
|
} else if count_keys > 1 {
|
||||||
let mut multi_data = tuple_list_1
|
let mut multi_data = tuple_list_1
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(a, _)| a == key)
|
.filter(|(a, _)| a == key)
|
||||||
@ -40,6 +43,8 @@ pub fn compile_hashmap(data: Vec<String>) -> Vec<(String, String)> {
|
|||||||
.collect::<Vec<&String>>();
|
.collect::<Vec<&String>>();
|
||||||
multi_data.sort_unstable_by(|a, b| compare_len_reverse_alpha(a, b));
|
multi_data.sort_unstable_by(|a, b| compare_len_reverse_alpha(a, b));
|
||||||
output.push((key.clone(), format!("Hint::Many(&{:?})", multi_data)));
|
output.push((key.clone(), format!("Hint::Many(&{:?})", multi_data)));
|
||||||
|
} else {
|
||||||
|
panic!("Number of values for {key} is 0!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
output
|
output
|
||||||
|
|||||||
@ -31,7 +31,9 @@ impl BackingFunction {
|
|||||||
match &parse_result {
|
match &parse_result {
|
||||||
Err(e) => return Err(e.to_string()),
|
Err(e) => return Err(e.to_string()),
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
let var_names = parse_result.as_ref().unwrap().var_names().to_vec();
|
let var_names = unsafe { parse_result.as_ref().unwrap_unchecked() }
|
||||||
|
.var_names()
|
||||||
|
.to_vec();
|
||||||
|
|
||||||
if var_names != ["x"] {
|
if var_names != ["x"] {
|
||||||
let var_names_not_x: Vec<&String> = var_names
|
let var_names_not_x: Vec<&String> = var_names
|
||||||
@ -50,7 +52,7 @@ impl BackingFunction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parse_result.unwrap()
|
unsafe { parse_result.unwrap_unchecked() }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -78,9 +78,9 @@ pub fn split_function_chars(chars: &[char]) -> Vec<String> {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn is_variable(&self) -> bool { self.variable && !self.masked_var }
|
const fn is_variable(&self) -> bool { self.variable && !self.masked_var }
|
||||||
|
|
||||||
fn is_number(&self) -> bool { self.number && !self.masked_num }
|
const fn is_number(&self) -> bool { self.number && !self.masked_num }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup first char here
|
// Setup first char here
|
||||||
@ -178,6 +178,10 @@ pub fn generate_hint<'a>(input: &str) -> &'a Hint<'a> {
|
|||||||
|
|
||||||
let chars: Vec<char> = input.chars().collect::<Vec<char>>();
|
let chars: Vec<char> = input.chars().collect::<Vec<char>>();
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
assume(!chars.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
let mut open_parens: usize = 0;
|
let mut open_parens: usize = 0;
|
||||||
let mut closed_parens: usize = 0;
|
let mut closed_parens: usize = 0;
|
||||||
chars.iter().for_each(|chr| match *chr {
|
chars.iter().for_each(|chr| match *chr {
|
||||||
@ -225,13 +229,13 @@ impl<'a> std::fmt::Debug for Hint<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Hint<'a> {
|
impl<'a> Hint<'a> {
|
||||||
pub fn is_none(&self) -> bool { matches!(&self, &Hint::None) }
|
pub const fn is_none(&self) -> bool { matches!(&self, &Hint::None) }
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn is_some(&self) -> bool { !self.is_none() }
|
pub const fn is_some(&self) -> bool { !self.is_none() }
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn is_single(&self) -> bool { matches!(&self, &Hint::Single(_)) }
|
pub const fn is_single(&self) -> bool { matches!(&self, &Hint::Single(_)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/codegen.rs"));
|
include!(concat!(env!("OUT_DIR"), "/codegen.rs"));
|
||||||
|
|||||||
@ -6,6 +6,7 @@ use serde_json::Value as JsonValue;
|
|||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
#[cfg(not(threading))]
|
#[cfg(not(threading))]
|
||||||
|
#[inline]
|
||||||
pub fn dyn_iter<'a, T>(input: &'a [T]) -> impl Iterator<Item = &'a T>
|
pub fn dyn_iter<'a, T>(input: &'a [T]) -> impl Iterator<Item = &'a T>
|
||||||
where
|
where
|
||||||
&'a [T]: IntoIterator,
|
&'a [T]: IntoIterator,
|
||||||
@ -14,6 +15,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(threading)]
|
#[cfg(threading)]
|
||||||
|
#[inline]
|
||||||
pub fn dyn_iter<'a, I>(input: &'a I) -> <&'a I as IntoParallelIterator>::Iter
|
pub fn dyn_iter<'a, I>(input: &'a I) -> <&'a I as IntoParallelIterator>::Iter
|
||||||
where
|
where
|
||||||
&'a I: IntoParallelIterator,
|
&'a I: IntoParallelIterator,
|
||||||
@ -22,6 +24,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(threading))]
|
#[cfg(not(threading))]
|
||||||
|
#[inline]
|
||||||
pub fn dyn_mut_iter<'a, T>(input: &'a mut [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
|
where
|
||||||
&'a mut [T]: IntoIterator,
|
&'a mut [T]: IntoIterator,
|
||||||
@ -30,6 +33,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(threading)]
|
#[cfg(threading)]
|
||||||
|
#[inline]
|
||||||
pub fn dyn_mut_iter<'a, I>(input: &'a mut I) -> <&'a mut I as IntoParallelIterator>::Iter
|
pub fn dyn_mut_iter<'a, I>(input: &'a mut I) -> <&'a mut I as IntoParallelIterator>::Iter
|
||||||
where
|
where
|
||||||
&'a mut I: IntoParallelIterator,
|
&'a mut I: IntoParallelIterator,
|
||||||
@ -114,10 +118,10 @@ impl SteppedVector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn get_min(&self) -> f64 { self.min }
|
pub const fn get_min(&self) -> f64 { self.min }
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn get_max(&self) -> f64 { self.max }
|
pub const fn get_max(&self) -> f64 { self.max }
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn get_data(&self) -> Vec<f64> { self.data.clone() }
|
pub fn get_data(&self) -> Vec<f64> { self.data.clone() }
|
||||||
|
|||||||
@ -34,19 +34,25 @@ impl<'a> const Default for AutoComplete<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> AutoComplete<'a> {
|
impl<'a> AutoComplete<'a> {
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn update_string(&mut self, string: &str) {
|
pub fn update_string(&mut self, string: &str) {
|
||||||
if self.string != string {
|
if self.string != string {
|
||||||
// catch empty strings here to avoid call to `generate_hint` and unnecessary logic
|
// catch empty strings here to avoid call to `generate_hint` and unnecessary logic
|
||||||
if string.is_empty() {
|
if string.is_empty() {
|
||||||
*self = Self::default();
|
*self = Self::default();
|
||||||
} else {
|
} else {
|
||||||
self.i = 0;
|
|
||||||
self.string = string.to_string();
|
self.string = string.to_string();
|
||||||
self.hint = generate_hint(string);
|
self.do_update_logic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Runs update logic assuming that a change to `self.string` has been made
|
||||||
|
fn do_update_logic(&mut self) {
|
||||||
|
self.i = 0;
|
||||||
|
self.hint = generate_hint(&self.string);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn register_movement(&mut self, movement: &Movement) {
|
pub fn register_movement(&mut self, movement: &Movement) {
|
||||||
if movement == &Movement::None {
|
if movement == &Movement::None {
|
||||||
return;
|
return;
|
||||||
@ -90,8 +96,8 @@ impl<'a> AutoComplete<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_hint(&mut self, hint: &str) {
|
pub fn apply_hint(&mut self, hint: &str) {
|
||||||
let new_string = self.string.clone() + hint;
|
self.string.push_str(hint);
|
||||||
self.update_string(&new_string);
|
self.do_update_logic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user