Closed micouy closed 3 years ago
Hi @micouy! I really like what you did, and the write-up is excellent. Thank you ❤️ I'd like to get this merged and see how people might use it.
Do you think you can make it compatible with stable Rust before we go on?
You mean the box
syntax? Sure thing, I can change it to Box::new
. What about the no_std
thing? I could change Continous(Box<dyn Fn + 'a>)
to Continous(&'a dyn Fn)
so as not to introduce more allocations, the enum already has the lifetime parameter. Since you're already breaking the API, you could also change it to use traits and move drawing logic to the shapes. Then you could merge my changes with the no_std
update but that would probably take ages without more contributors.
I'm fine with dropping no_std
support idea. I'm not yet sure there is a lot of utility in a library like that on embedded device.
Done. I've added one example with box
syntax in README.md
and in src/lib.rs
. Just remove them if you do not wish them to be there. Remember to say something about the binary in README.md
. I also suggest adding a small demo.
This PR adds a binary of the same name to the crate. It introduces a breaking change in the API. Resolves #21, resolves #20.
Changes
src/main.rs
.Change
Shape::Continous
insrc/lib.rs
.Before:
After:
This is a breaking change in the API, so the minor version must be increased. I explained the motivation behind it in #21. I don't believe it is possible to add a dynamic math expression parser without introducing this change.
I also added
#![feature(box_syntax)]
on top of every example andbox
before each closure, including the examples in documentation andREADME.md
. If you do not wish to include this line each time you can switch to stable syntax:Box::new(...)
. Alternative solutions are provided in #21.This change is incompatible with #14 (
no_std
support) as it requires allocatingBox
es. A possible solution is to use references or generic types inShape
. Another solution is to move drawing logic fromChart
to shapes and introduce aShape
trait instead of an enum with predefined types in its fields.Cargo.toml
to0.6.0
.Set
edition = "2018"
inCargo.toml
. Add bin and lib sections toCargo.toml
.This makes configuring a separate binary and library easier. I also removed each
extern crate
since they are not necessary in the 2018 edition.clap
to parse args and display pretty info about the binary.meval
to parse math expressions.Behavior
Basic usage (prints the formula and displays the plot)
Error info on no formula
--help
Error info on unknown variable
Error on unexpected token
Possible future development