Crates.io | yash-arith |
lib.rs | yash-arith |
version | 0.2.1 |
source | src |
created_at | 2022-10-01 02:18:04.531319 |
updated_at | 2023-11-11 15:14:28.60691 |
description | POSIX shell arithmetic expansion |
homepage | |
repository | https://github.com/magicant/yash-rs |
max_upload_size | |
id | 677592 |
size | 200,665 |
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
.
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.