yash-arith
is a Rust library crate for performing the POSIX shell's arithmetic
expansion. This crate is part of yash but can be used
independently.
Add yash-arith
as a dependency in your Cargo.toml
.
rust
use std::collections::HashMap;
use yash_arith::{eval, Value};
let mut env = HashMap::new();
env.insert("a".to_owned(), "2".to_owned());
let result = eval("1 + a", &mut env);
assert_eq!(result, Ok(Value::Integer(3)));
This crate is distributed under GPLv3.