| Crates.io | calculator-rs |
| lib.rs | calculator-rs |
| version | 0.1.2 |
| created_at | 2023-11-09 13:11:38.112023+00 |
| updated_at | 2023-11-09 13:17:05.297704+00 |
| description | Calculator is a library which support calculates the value of string |
| homepage | https://github.com/misssonder/calculator |
| repository | https://github.com/misssonder/calculator |
| max_upload_size | |
| id | 1030163 |
| size | 35,424 |
Calculator is a library which support calculates the value of string.
[dependencies]
calculator-rs = { version = "*" }
fn main(){
{
let calculator = "1+1".calculate();
assert_eq!(calculator, Ok(Value::Integer(2)))
}
{
let calculator = "1*1".calculate();
assert_eq!(calculator, Ok(Value::Integer(1)))
}
{
let calculator = "2*4".calculate();
assert_eq!(calculator, Ok(Value::Integer(8)))
}
{
let calculator = "4!".calculate();
assert_eq!(calculator, Ok(Value::Integer(24)))
}
{
let calculator = "31%15".calculate();
assert_eq!(calculator, Ok(Value::Integer(1)))
}
{
let calculator = "1*!1".calculate();
assert!(calculator.is_err())
}
}