Crates.io | my_parser_striletska |
lib.rs | my_parser_striletska |
version | 0.1.1 |
source | src |
created_at | 2024-10-23 12:44:18.789133 |
updated_at | 2024-10-23 12:54:07.801445 |
description | A simple parser, that parses lists of integers from string format |
homepage | |
repository | https://github.com/KatyaStriletska/my-first-parser |
max_upload_size | |
id | 1420025 |
size | 3,944 |
It is a simple parser for education purposes. It allows you to parse numbers in string format.
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),
}
}