[][src]Crate math_calc

About

Welcome to the documentation for math-calc! This is a simple arithmatic library that gets an inputted String, u8 slice or a plain &str and outputs the finished calculation.

This essentially means you can input multiple calculations seperated by a , (similar to how JSON can be used) and get a Vec<i32> containing the finished calculations.

Examples

A basic parsing of a &str directly:

use math_calc::{ErrorKind, parse_str};

fn main() {
    // Expected returns: 1st: 3, 2nd: 110, 3rd: 123
    let inputted_calculations = "1 + 2, 550 / 5, 8 * 16 + (-25 / 5)";
     
    // Generate results
    let output_vec: Vec<i32> = parse_str(inputted_calculations).unwrap();

    // Output results of calculation
    println!("Calculation results (in vector):\n\n{:?}", output_vec);
}

Enums

ErrorKind

Primary error enum that is used on frontend functions to enable proper error parsing downstream.

Functions

parse_str

Parses a given str into the expected Vec<i32> result.

parse_u8_slice

Parses a given u8 slice into the expected Vec<i32> result.