about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi <fredmanglis@gmail.com>2022-08-06 07:45:19 +0300
committerFrederick Muriuki Muriithi <fredmanglis@gmail.com>2022-08-06 07:47:16 +0300
commit809a26505b5ceaf488151ba859f1a986d757b582 (patch)
treee80768b6b1ba630ac5e674366f98c46df11617d8 /src
parent1c2b508720e3918dbf814b584f7adae00b901a10 (diff)
downloadcorrelation_rust-809a26505b5ceaf488151ba859f1a986d757b582.tar.gz
Remove unnecessary parsing
JSON already has a way to denote an array of objects, so there is no
need to manually parse such arrays from strings.
Diffstat (limited to 'src')
-rw-r--r--src/analysis.rs6
-rw-r--r--src/parser.rs2
2 files changed, 2 insertions, 6 deletions
diff --git a/src/analysis.rs b/src/analysis.rs
index 08486a9..886e498 100644
--- a/src/analysis.rs
+++ b/src/analysis.rs
@@ -8,11 +8,7 @@ impl Analysis {
 
         //above should return  a results
 
-        let x_vals: Vec<f64> = json_results
-            .x_vals
-            .split(",")
-            .map(|f| f.trim().parse::<f64>().unwrap())
-            .collect();
+        let x_vals: Vec<f64> = json_results.x_vals;
 
         let computation = correlations::Compute::new(
             json_results.file_delimiter,
diff --git a/src/parser.rs b/src/parser.rs
index 97ed18a..2e263f8 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -6,7 +6,7 @@ use std::io::Read;
 
 pub struct JsonData {
     pub file_path: String,
-    pub x_vals: String,
+    pub x_vals: Vec<f64>,
     pub sample_values: String,
     pub method: String,
     pub file_delimiter: char,