Function parse_line

Source
pub fn parse_line(i: &str) -> Result<Vec<Vec<DiceRollWithOp>>, ParserError>
Expand description

Takes a string of dice input and returns a Result<DiceRoll, ParserError>

The string will be consumed in the process and must strictly match the format of the parser.

§Examples

Standard usage:

use dice_command_parser::{parse_line, error::ParserError};

let input = "3d6 - 5";
let dice_roll = parse_line(&input)?;

§Errors

This function can fail when one of the following occurs

  1. The line failed to parse.
  2. An error occurred parsing the numbers provided. This will likely be an overflow or underflow error.

For more information see ParserError.