Skip to main content

parse

Function parse 

Source
pub fn parse(input: &str) -> Result<Nth, ParseError>
Expand description

Parse an An+B expression such as "2n+1", "odd", "even", "-n+3", or "5".

§Errors

Returns ParseError if input is not a valid An+B expression. Coefficients are i32; a magnitude outside the i32 range also returns ParseError.

let n = nth_check::parse("2n+1").unwrap();
assert_eq!((n.a(), n.b()), (2, 1));