Module prelude

Source
Expand description

A giant sack of toys and goodies to import along with parser!.

The parser!() macro will work fine without this, so you can explicitly import the names you want to use instead of doing use aoc_parse::{parser, prelude::*};.

This includes some constants that have the same name as a built-in Rust type: i32, usize, bool, and so on. There’s no conflict because Rust types and constants live in separate namespaces.

Constants§

alnum
Matches any alphabetic or numeric character (see char::is_alphanumeric). Returns a char.
alpha
Matches any alphabetic character (see char::is_alphabetic). Returns a char.
any_char
Matches any Unicode character. Returns a char.
big_int
Parse a BigInt (using its FromStr implementation in the num-bigint crate, except that underscores between digits are not accepted).
big_int_bin
Parse a BigInt written in base 2 (using its Num impl from the num-bigint crate, except that underscores between digits are not accepted).
big_int_hex
Parse a BigInt written in base 16 (using its Num impl from the num-bigint crate, except that underscores between digits are not accepted).
big_uint
Parse a BigUint (using its FromStr implementation in the num-bigint crate, except that underscores between digits are not accepted and a leading + sign is not accepted).
big_uint_bin
Parse a BigUint written in base 2 (using its Num impl from the num-bigint crate, except that underscores between digits are not accepted and a leading + sign is not accepted).
big_uint_hex
Parse a BigUint written in base 16 (using its Num impl from the num-bigint crate, except that underscores between digits are not accepted and a leading + sign is not accepted).
bool
Parse a value of a primitive type (using its FromStr implementation in the Rust standard library).
digit
Matches any ASCII decimal digit '0'-'9' and converts it to its integer value 0-9.
digit_bin
Matches a binary digit '0' or '1', and converts it to its integer value 0 or 1.
digit_hex
Matches a hexadecimal digit '0'-'9', 'a'-'f', or 'A'-'F', and converts it to its integer value 0-15.
f32
Parse a value of a primitive type (using its FromStr implementation in the Rust standard library).
f64
Parse a value of a primitive type (using its FromStr implementation in the Rust standard library).
i8
Parse a value of a primitive type (using its FromStr implementation in the Rust standard library).
i8_bin
Parse an integer written in base 2, using the from_str_radix static method from the Rust standard library.
i8_hex
Parse an integer written in base 16, using the from_str_radix static method from the Rust standard library.
i16
Parse a value of a primitive type (using its FromStr implementation in the Rust standard library).
i32
Parse a value of a primitive type (using its FromStr implementation in the Rust standard library).
i64
Parse a value of a primitive type (using its FromStr implementation in the Rust standard library).
i16_bin
Parse an integer written in base 2, using the from_str_radix static method from the Rust standard library.
i16_hex
Parse an integer written in base 16, using the from_str_radix static method from the Rust standard library.
i32_bin
Parse an integer written in base 2, using the from_str_radix static method from the Rust standard library.
i32_hex
Parse an integer written in base 16, using the from_str_radix static method from the Rust standard library.
i64_bin
Parse an integer written in base 2, using the from_str_radix static method from the Rust standard library.
i64_hex
Parse an integer written in base 16, using the from_str_radix static method from the Rust standard library.
i128
Parse a value of a primitive type (using its FromStr implementation in the Rust standard library).
i128_bin
Parse an integer written in base 2, using the from_str_radix static method from the Rust standard library.
i128_hex
Parse an integer written in base 16, using the from_str_radix static method from the Rust standard library.
isize
Parse a value of a primitive type (using its FromStr implementation in the Rust standard library).
isize_bin
Parse an integer written in base 2, using the from_str_radix static method from the Rust standard library.
isize_hex
Parse an integer written in base 16, using the from_str_radix static method from the Rust standard library.
lower
Matches any lowercase letter (see char::is_lowercase). Returns a char.
u8
Parse a value of a primitive type (using its FromStr implementation in the Rust standard library).
u8_bin
Parse an integer written in base 2, using the from_str_radix static method from the Rust standard library.
u8_hex
Parse an integer written in base 16, using the from_str_radix static method from the Rust standard library.
u16
Parse a value of a primitive type (using its FromStr implementation in the Rust standard library).
u32
Parse a value of a primitive type (using its FromStr implementation in the Rust standard library).
u64
Parse a value of a primitive type (using its FromStr implementation in the Rust standard library).
u16_bin
Parse an integer written in base 2, using the from_str_radix static method from the Rust standard library.
u16_hex
Parse an integer written in base 16, using the from_str_radix static method from the Rust standard library.
u32_bin
Parse an integer written in base 2, using the from_str_radix static method from the Rust standard library.
u32_hex
Parse an integer written in base 16, using the from_str_radix static method from the Rust standard library.
u64_bin
Parse an integer written in base 2, using the from_str_radix static method from the Rust standard library.
u64_hex
Parse an integer written in base 16, using the from_str_radix static method from the Rust standard library.
u128
Parse a value of a primitive type (using its FromStr implementation in the Rust standard library).
u128_bin
Parse an integer written in base 2, using the from_str_radix static method from the Rust standard library.
u128_hex
Parse an integer written in base 16, using the from_str_radix static method from the Rust standard library.
upper
Matches any uppercase letter (see char::is_uppercase). Returns a char.
usize
Parse a value of a primitive type (using its FromStr implementation in the Rust standard library).
usize_bin
Parse an integer written in base 2, using the from_str_radix static method from the Rust standard library.
usize_hex
Parse an integer written in base 16, using the from_str_radix static method from the Rust standard library.

Traits§

Parser
Trait implemented by all parsers.

Functions§

btree_map
Convert the output of parser from a Vec<(K, V)> or other collection of pairs into a BTreeMap.
btree_set
Convert the output of parser from a Vec<V> or other collection into a BTreeSet.
char_of
Make a parser that matches any single character in options and produces the index of that character in the list, so that char_of("ABCD") produces a number in 0..4.
hash_map
Convert the output of parser from a Vec<(K, V)> or other collection of pairs into a HashMap.
hash_set
Convert the output of parser from a Vec<V> or other collection into a HashSet.
line
line(pattern) matches a single line of text that matches pattern, and the newline at the end of the line.
lines
lines(pattern) matches any number of lines of text matching pattern. Each line must be terminated by a newline, '\n'.
repeat_sep
repeat_sep(pattern, separator) matches the given pattern any number of times, separated by the separator. For example, parser!(repeat_sep(i32, ",")) matches a list of comma-separated integers.
section
section(pattern) matches zero or more nonblank lines, followed by either a blank line or the end of input. The nonblank lines must match pattern.
sections
sections(pattern) matches any number of sections matching pattern. Equivalent to section(pattern)*.
string
Parse using parser, but instead of converting the matched text to a Rust value, simply return it as a String.
vec_deque
Convert the output of parser from a Vec<V> or other collection into a VecDeque.