likebike / fasteval

Fast and safe evaluation of algebraic expressions
https://crates.io/crates/fasteval/
MIT License
267 stars 26 forks source link

no_std availability #4

Open chrysn opened 4 years ago

chrysn commented 4 years ago

From a brief look over the code (and judging from the explanations around slabs in the docs), fasteval should be easily usable on platforms without dynamic memory allocation. Some features around the "easy use" parts might be unavailable, but that wouldn't hurt too much.

A typical way this can be done in recent (2018) Rust versions is to convert what can be done to from std:: to core:: (eg. core::mem), and cfg-gate everything that does need real standard library features (implementing std::error, file I/O) behind a new and default std feature. Thus, regular users see no change, but embedded users will set default-features to false.

One use case where this would come in handy is embedded devices, which could then be configurable with custom expressions rather than only static parameters (think configuring the intensity of a floor light as ((t < 300) && 1) || max(0, (t - 305) / 5, (t - 310) / 20) instead of configuring a runtime of 5 minutes and a fade-out time of 10 seconds with no hopes to customize the fading).

Please consider supporting no_std for this crate.

likebike commented 4 years ago

This is a great idea. Thanks! I'll do this when I get some time.