Repository: nw-rs/citrus-cas (language: rust)

Issue:
Move example code
Example code should either be moved to an `examples` directory or be expanded on to create a more full featured application.
Not urgent, can be left as is for beta/pre-release purposes, but should be done before an actual release.


Discussion / hints:

Fix patch:
diff --git a/Cargo.lock b/Cargo.lock
index 21c0d20..cd014fc 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -11,12 +11,6 @@ dependencies = [
  "memchr",
 ]
 
-[[package]]
-name = "arrayvec"
-version = "0.7.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
-
 [[package]]
 name = "atomic-polyfill"
 version = "0.1.8"
@@ -155,6 +149,12 @@ version = "2.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"
 
+[[package]]
+name = "minimal-lexical"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
+
 [[package]]
 name = "nb"
 version = "0.1.3"
@@ -172,19 +172,18 @@ checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae"
 
 [[package]]
 name = "nom"
-version = "6.1.2"
+version = "7.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2"
+checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
 dependencies = [
  "memchr",
- "version_check",
+ "minimal-lexical",
 ]
 
 [[package]]
 name = "rcas"
 version = "0.1.0"
 dependencies = [
- "arrayvec",
  "heapless",
  "libm",
  "nom",
@@ -294,12 +293,6 @@ version = "0.1.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002"
 
-[[package]]
-name = "version_check"
-version = "0.9.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
-
 [[package]]
 name = "void"
 version = "1.0.2"
diff --git a/Cargo.toml b/Cargo.toml
index bd0ced7..e09a422 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,7 +2,7 @@
 name = "rcas"
 version = "0.1.0"
 authors = ["willemml <willem@leit.so>"]
-edition = "2018"
+edition = "2021"
 license = "GPL-3.0"
 description = "CAS (Computer Algebra System) for no_std environements."
 repository = "https://github.com/willemml/rcas"
@@ -10,7 +10,14 @@ repository = "https://github.com/willemml/rcas"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-nom = { version = "6", default-features = false }
-arrayvec = { version = "0.7.2", default-features = false, optional = true }
+nom = { version = "7.1.1", default-features = false }
 heapless = "0.7.14"
 libm = "0.2.2"
+
+[lib]
+name = "rcas"
+path = "src/lib.rs"
+
+[[bin]]
+name = "rcas_cli"
+path = "src/bin/bin.rs"
diff --git a/src/main.rs b/src/bin/bin.rs
similarity index 99%
rename from src/main.rs
rename to src/bin/bin.rs
index b5033dd..76313d0 100644
--- a/src/main.rs
+++ b/src/bin/bin.rs
@@ -28,7 +28,7 @@ fn main() {
             .expect("Failed to read line");
 
         let eval_result = rcas::parse_evaluation::<500>(&input);
-        let approx_result = rcas::parse_approximation(&input, &map);
+        let approx_result = rcas::parse_approximation(&input, &map_collection);
 
         if eval_result.is_ok() {
             println!("eval: {}", eval_result.unwrap().to_string());
diff --git a/src/expression_map.rs b/src/expression_map.rs
index 377c5b1..2f1dc2a 100644
--- a/src/expression_map.rs
+++ b/src/expression_map.rs
@@ -111,7 +111,7 @@ impl<const E: usize, const L: usize, const V: usize> ExpressionMap<E> for UserFu
                 continue;
             }
             
-            skip = 1; //skip the terminator
+            skip = 0; //skip the terminator
             match token {
                 Token::Func(func) => {
                     let mut arguments: Vec<Vec::<Token, V>, V> = Vec::new();
diff --git a/src/parser.rs b/src/parser.rs
index e6d8875..91c3477 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -1,9 +1,6 @@
 use core::str::FromStr;
 
-use heapless::{
-    LinearMap, 
-    Vec,
-};
+use heapless::Vec;
 
 use nom::{
     branch::alt,
@@ -75,7 +72,7 @@ fn math_token(i: &str) -> IResult<&str, Token, Error<&str>> {
 }
 
 pub fn math_expr<const E: usize>(i: &str) -> IResult<&str, Vec<Token, E>, Error<&str>> {
-    fold_many0(complete(math_token), Vec::new(), |mut acc, t| {
+    fold_many0(complete(math_token), Vec::new, |mut acc, t| {
         acc.push(t).expect("Not enough memory."); //TODO: make this return an error instead of panicking
         acc
     })(i)


Test patch: