mirror of
https://github.com/redox-os/calc
synced 2026-08-25 07:36:07 +00:00
No description
- Rust 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Fix issue https://gitlab.redox-os.org/redox-os/calc/-/issues/29 and version bump Closes #29 See merge request redox-os/calc!31 |
||
| .github | ||
| src | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| .travis.yml | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
| rustfmt.toml | ||
calc
calc is a Rust library for tokenizing and evaluating arithmetic expressions with a command line application of the same name included.
NOTE: The name of the project, binary, and library are calc but the package name is calculate. This will remain depending on if this project can acquire the calc crate which is currently being squatted on.
Usage
As a Library
Add calc as a dependency in your Cargo.toml:
[dependencies]
calculate = "0.5.*"
Then make use of the library functions:
extern crate calc;
use calc::eval;
use std::io::{self, BufRead, stdout, stdin, Write};
fn main() {
let stdout = stdout();
let mut stdout = stdout.lock();
let stdin = stdin();
for line in stdin.lock().lines() {
match line.unwrap().trim() {
"" => (),
"exit" => break,
s => writeln!(stdout, "{}", eval(s)).unwrap(),
}
}
}
As an Executable
$ cargo install calculate
...
$ calc