shroom 0.0.1

A library for evaluating strings as expressions. This is an experimental version, the crate is unstable and most of the features are yet to be tested.
Documentation
  • Coverage
  • 27.08%
    13 out of 48 items documented2 out of 41 items with examples
  • Size
  • Source code size: 118.6 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.53 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 33s Average build duration of successful builds.
  • all releases: 33s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • XullTheEaterOfWorlds

Shroom

A library for evaluating strings as expressions.
This is an experimental version. The crate is unstable and most of the features are yet to be tested.

Example usage:

// construct a new shroom instance
let shrm = Shroom::new();

// `eval` returns a `Result` containing a shroom primitive value on success
// or an error message on fail.
// A shroom primitive value can be an integer, a floating point number, a boolean value or a string.
// Calling `unwrap_int` on a primitive value returns the value as i64 or panics if it is not an integer.
let result = shrm.eval("2 + 3 * 4").unwrap().unwrap_int();

println!("2 + 3 * 4 = {}", result);

Output:

2 + 3 * 4 = 14

A shroom expression can contain decimal, hexadecimal (with prefix 0x), octal (0o) and binary (0b) integers, floating point numbers (basic decimal and scientific notation), boolean values (true or false), strings (enclosed in ") and the following binary operators:

  • + - * / ** % : basic arithmetic operations, exponentiation and remainder
  • & | ^ << >> : bitwise operations
  • > < >= <= != == : comparisons
  • && || : logical operations + can be used for string concatenation