my_parser_striletska

Crates.iomy_parser_striletska
lib.rsmy_parser_striletska
version0.1.1
sourcesrc
created_at2024-10-23 12:44:18.789133
updated_at2024-10-23 12:54:07.801445
descriptionA simple parser, that parses lists of integers from string format
homepage
repositoryhttps://github.com/KatyaStriletska/my-first-parser
max_upload_size
id1420025
size3,944
(KatyaStriletska)

documentation

README

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),
    }
}
Commit count: 6

cargo fmt