#parser #string-format #list #integer #striletska

bin+lib my_parser_striletska

A simple parser, that parses lists of integers from string format

2 releases

0.1.1 Oct 23, 2024
0.1.0 Oct 23, 2024

#1272 in Parser implementations

Download history 221/week @ 2024-10-22 7/week @ 2024-10-29 5/week @ 2024-11-05

233 downloads per month

MIT license

3KB

My parser

It is a simple parser for education purposes. It allows you to parse numbers in string format.

alt text

Examples

Parsing the correct list:

use my_parser_striletska::list_parser;
fn main() {
    assert_eq!(list_parser::list("[1,1,2,3,5,8]"), Ok(vec![1, 1, 2, 3, 5, 8]));
}

Handling parsing errors:

use my_parser_striletska::list_parser;
fn main() {
    let input = "[1,a]";
    match list_parser::list(input) {
        Ok(parsed) => println!("Parsed list: {:?}", parsed),
        Err(err) => println!("Error: {:?}", err),
    }
}

Dependencies

~145KB