rustfmt
This commit is contained in:
parent
7a00ed62f6
commit
1dc42105f2
@ -233,9 +233,7 @@ impl ChartManager {
|
|||||||
|
|
||||||
// Creates and does the math for creating all the rectangles under the graph
|
// Creates and does the math for creating all the rectangles under the graph
|
||||||
#[inline]
|
#[inline]
|
||||||
fn integral_rectangles(
|
fn integral_rectangles(&self, step: f32) -> (Vec<(f32, f32, f32)>, f32) {
|
||||||
&self, step: f32
|
|
||||||
) -> (Vec<(f32, f32, f32)>, f32) {
|
|
||||||
let data2: Vec<(f32, f32, f32)> = (0..self.num_interval)
|
let data2: Vec<(f32, f32, f32)> = (0..self.num_interval)
|
||||||
.map(|e| {
|
.map(|e| {
|
||||||
let x: f32 = ((e as f32) * step) + self.min_x;
|
let x: f32 = ((e as f32) * step) + self.min_x;
|
||||||
|
|||||||
20
src/misc.rs
20
src/misc.rs
@ -1,5 +1,5 @@
|
|||||||
use wasm_bindgen::prelude::*;
|
|
||||||
use meval::Expr;
|
use meval::Expr;
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
pub type DrawResult<T> = Result<T, Box<dyn std::error::Error>>;
|
pub type DrawResult<T> = Result<T, Box<dyn std::error::Error>>;
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ pub fn add_asterisks(function_in: String) -> String {
|
|||||||
|
|
||||||
pub struct Function {
|
pub struct Function {
|
||||||
function: Box<dyn Fn(f64) -> f64>,
|
function: Box<dyn Fn(f64) -> f64>,
|
||||||
func_str: String
|
func_str: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Function {
|
impl Function {
|
||||||
@ -99,24 +99,17 @@ impl Function {
|
|||||||
let func = expr.bind("x").unwrap();
|
let func = expr.bind("x").unwrap();
|
||||||
Self {
|
Self {
|
||||||
function: Box::new(func),
|
function: Box::new(func),
|
||||||
func_str
|
func_str,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn run(&self, x: f32) -> f32 {
|
pub fn run(&self, x: f32) -> f32 { (self.function)(x as f64) as f32 }
|
||||||
(self.function)(x as f64) as f32
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn str_compare(&self, other_string: String) -> bool {
|
pub fn str_compare(&self, other_string: String) -> bool { self.func_str == other_string }
|
||||||
self.func_str == other_string
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_string(&self) -> String {
|
pub fn get_string(&self) -> String { self.func_str.clone() }
|
||||||
self.func_str.clone()
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Result of screen to chart coordinates conversion.
|
/// Result of screen to chart coordinates conversion.
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
@ -211,7 +204,6 @@ fn asterisk_test() {
|
|||||||
assert_eq!(&add_asterisks("x!".to_string()), "x!");
|
assert_eq!(&add_asterisks("x!".to_string()), "x!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Tests cache when initialized with value
|
// Tests cache when initialized with value
|
||||||
#[test]
|
#[test]
|
||||||
fn cache_test_full() {
|
fn cache_test_full() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user