From e5eefc1a70ac6f7be2ba7b342aacbae231ff234a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Falc=C3=A3o?= Date: Sat, 18 Oct 2025 17:21:20 +0000 Subject: [PATCH 1/8] updates rustfmt --- rustfmt.toml | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/rustfmt.toml b/rustfmt.toml index 346c9d288..fd283ca26 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1,78 @@ -tab_spaces = 2 -max_width = 100 +# ignore = [] # Skip formatting the specified files and directories +# verbose = "Quiet" # How much to information to emit to the user (Verbose, Normal, Quiet) +array_width = 42 # Maximum width of an array literal before falling back to vertical formatting. +attr_fn_like_width = 20 # Maximum width of the args of a function-like attributes before falling back to vertical formatting. +chain_width = 50 # Maximum length of a chain to fit on a single line. +comment_width = 80 # Maximum length of comments. No effect unless wrap_comments = true +doc_comment_code_block_width = 100 # Maximum width for code snippets in doc comments. No effect unless format_code_in_doc_comments = true +fn_call_width = 57 # Maximum width of the args of a function call before falling back to vertical formatting. +inline_attribute_width = 0 # Write an item and its attribute on the same line if their combined width is below a threshold +max_width = 80 # Maximum width of each line +short_array_element_width_threshold = 10# Width threshold for an array element to be considered short +single_line_if_else_max_width = 20 # Maximum line length for single line if-else expressions. A value of zero means always break if-else expressions. +single_line_let_else_max_width = 20 # Maximum line length for single line let-else statements. A value of zero means always format the divergent `else` block over multiple lines. +struct_lit_width = 18 # Maximum width in the body of a struct lit before falling back to vertical formatting. +struct_variant_width = 35 # Maximum width in the body of a struct variant before falling back to vertical formatting. +binop_separator = "Front" # Where to put a binary operator when a binary expression goes multiline +blank_lines_lower_bound = 0 # Minimum number of blank lines which must be put between items +blank_lines_upper_bound = 1 # Maximum number of blank lines which can be put between items +brace_style = "SameLineWhere" # Brace style for items +color = "Auto" # What Color option to use when none is supplied = Always, Never, Auto +combine_control_expr = true # Combine control expressions with function calls +condense_wildcard_suffixes = false # Replace strings of _ wildcards by a single .. in tuple patterns +control_brace_style = "AlwaysSameLine" # Brace style for control flow constructs +disable_all_formatting = false # Don't reformat anything +edition = "2021" # The edition of the parser (RFC 2052) +emit_mode = "Files" # What emit Mode to use when none is supplied +empty_item_single_line = true # Put empty-body functions and impls on a single line +enum_discrim_align_threshold = 0 # Align enum variants discrims, if their diffs fit within threshold +error_on_line_overflow = false # Error if unable to get all lines within max_width +error_on_unformatted = false # Error if unable to get comments or string literals within max_width, or they are left with trailing whitespaces +fn_params_layout = "Tall" # Control the layout of parameters in function signatures. +fn_single_line = false # Put single-expression functions on a single line +force_explicit_abi = true # Always print the abi for extern items +force_multiline_blocks = false # Force multiline closure bodies and match arms to be wrapped in a block +format_code_in_doc_comments = false # Format the code snippet in doc comments. +format_generated_files = true # Format generated files +format_macro_bodies = true # Format the bodies of declarative macro definitions +format_macro_matchers = true # Format the metavariable matching patterns in macros +format_strings = false # Format string literals where necessary +group_imports = "StdExternalCrate" # Controls the strategy for how imports are grouped together: Preserve, StdExternalCrate or One +hard_tabs = false # Use tab characters for indentation, spaces for alignment +# tab_spaces = 2 # Number of spaces per tab +hex_literal_case = "Upper" # Format hexadecimal integer literals +show_parse_errors = true # +imports_granularity = "Module" # Merge or split imports to the provided granularity + # imports_granularity options: "Preserve": "Do not merge imports" /"Crate": "Use one `use` statement per crate" / "Module": "Use one `use` statement per module" / "Item": " Use one `use` statement per imported item" / "One": Use one `use` statement including all items) +imports_indent = "Block" # Indent of imports +imports_layout = "Mixed" # Item layout inside a import block +indent_style = "Block" # How do we indent expressions or items +make_backup = false # Backup changed files +match_arm_blocks = false # Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms +match_arm_leading_pipes = "Never" # Determines whether leading pipes are emitted on match arms +match_block_trailing_comma = true # Put a trailing comma after a block based match arm (non-block arms are not affected) +merge_derives = true # Merge multiple ` #[derive(...)]` into a single one +newline_style = "Auto" # Unix or Windows line endings +normalize_doc_attributes = false # Normalize doc attributes as doc comments +overflow_delimited_expr = false # Allow trailing bracket/brace delimited expressions to overflow +print_misformatted_file_names = true # Prints the names of mismatched files that were formatted. Prints the names of files that would be formatted when used with `--check` mode. +remove_nested_parens = true # Remove nested parens +reorder_impl_items = true # Reorder impl items +reorder_imports = true # Reorder import and extern crate statements alphabetically +reorder_modules = true # Reorder module statements alphabetically in group +required_version = "1.8.0" +skip_children = false # Don't reformat out of line modules +space_after_colon = true # Leave a space after the colon +space_before_colon = false # Leave a space before the colon +spaces_around_ranges = false # Put spaces around the .. and ..= range operators +struct_field_align_threshold = 0 # Align struct fields if their diffs fits within threshold +struct_lit_single_line = true # Put small struct literals on a single line +trailing_comma = "Vertical" # How to handle trailing commas for lists +trailing_semicolon = true # Add trailing semicolon after break, continue and return +type_punctuation_density = "Wide" # Determines if '+' or '=' are wrapped in spaces in the punctuation of types +unstable_features = false # Enables unstable features. Only available on nightly channel +use_field_init_shorthand = false # Use field initialization shorthand if possible +use_small_heuristics = "Max" # Whether to use different formatting for items and expressions if they satisfy a heuristic notion of 'small' +use_try_shorthand = true # Replace uses of the try! macro by the ? shorthand +where_single_line = false # Force where-clauses to be on a single line +wrap_comments = false # Break comments to fit on the line From f0d6334b924d2a4eb37d48eead62de71a9819e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Falc=C3=A3o?= Date: Sat, 18 Oct 2025 17:22:48 +0000 Subject: [PATCH 2/8] expose guides from doc/*.md within rustdoc under module "guides" --- src/lib.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index c82715a3b..95574a5d8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -440,6 +440,7 @@ mod macros; pub mod error; pub mod branch; + pub mod combinator; mod internal; pub mod multi; @@ -458,3 +459,22 @@ pub mod number; #[cfg(all(feature = "std", any(doc, doctest, feature = "docsrs")))] #[cfg_attr(any(doc, doctest, feature = "docsrs"), doc = include_str!("../doc/nom_recipes.md"))] pub mod recipes {} + +#[doc = include_str!("../doc/home.md")] +pub mod guides { + + #[doc = include_str!("../doc/choosing_a_combinator.md")] + pub mod choosing_a_combinator {} + #[doc = include_str!("../doc/custom_input_types.md")] + pub mod custom_input_types {} + #[doc = include_str!("../doc/error_management.md")] + pub mod error_management {} + // #[doc = include_str!("../doc/home.md")] + // pub mod home {} + #[doc = include_str!("../doc/making_a_new_parser_from_scratch.md")] + pub mod making_a_new_parser_from_scratch {} + #[doc = include_str!("../doc/nom_recipes.md")] + pub mod nom_recipes {} + #[doc = include_str!("../doc/upgrading_to_nom_5.md")] + pub mod upgrading_to_nom_5 {} +} From 878e53f41baf7fd485fd0e48977f08ac77bf1092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Falc=C3=A3o?= Date: Sat, 18 Oct 2025 21:38:57 +0000 Subject: [PATCH 3/8] add macro attributes to expose guides as a module in rustdoc --- src/lib.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 95574a5d8..f0239c017 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -460,7 +460,9 @@ pub mod number; #[cfg_attr(any(doc, doctest, feature = "docsrs"), doc = include_str!("../doc/nom_recipes.md"))] pub mod recipes {} -#[doc = include_str!("../doc/home.md")] + +#[cfg(all(feature = "std", any(doc, doctest, feature = "docsrs")))] +#[cfg_attr(any(doc, doctest, feature = "docsrs"), doc = include_str!("../doc/home.md"))] pub mod guides { #[doc = include_str!("../doc/choosing_a_combinator.md")] @@ -469,12 +471,8 @@ pub mod guides { pub mod custom_input_types {} #[doc = include_str!("../doc/error_management.md")] pub mod error_management {} - // #[doc = include_str!("../doc/home.md")] - // pub mod home {} #[doc = include_str!("../doc/making_a_new_parser_from_scratch.md")] pub mod making_a_new_parser_from_scratch {} - #[doc = include_str!("../doc/nom_recipes.md")] - pub mod nom_recipes {} #[doc = include_str!("../doc/upgrading_to_nom_5.md")] pub mod upgrading_to_nom_5 {} } From fc71d05936f97e3a9a545972165be6d87a5014e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Falc=C3=A3o?= Date: Sat, 18 Oct 2025 21:39:50 +0000 Subject: [PATCH 4/8] fixup doc/home.md links to point rustdoc guides module --- doc/home.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/home.md b/doc/home.md index 52b56ba8d..27294f3df 100644 --- a/doc/home.md +++ b/doc/home.md @@ -3,10 +3,10 @@ To get started using nom, you can include it in your Rust projects from [crates.io](https://crates.io/crates/nom). Here are a few links you will find useful: -* [Reference documentation](https://docs.rs/nom) +* [Reference documentation](crate) * [Gitter chat room](https://gitter.im/Geal/nom). You can also go to the #nom IRC channel on irc.mozilla.org, or ping 'geal' on Mozilla, Freenode, Geeknode or oftc IRC -* [Making a new parser from scratch](making_a_new_parser_from_scratch.md) +* [Making a new parser from scratch](crate::guides::making_a_new_parser_from_scratch) (general tips on writing a parser and code architecture) -* [How to handle parser errors](error_management.md) -* [Recipes for common nom tasks](nom_recipes.md) +* [How to handle parser errors](crate::guides::error_management) +* [Recipes for common nom tasks](crate::recipes) From 5d74ea6689162c6f859640b60f9531ec221abab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Falc=C3=A3o?= Date: Sat, 18 Oct 2025 21:41:07 +0000 Subject: [PATCH 5/8] introduce fixup.sh script to automatically "fixup" links in markdown docs doc/**.md, changing hardcoded links of crate item docs from https:/docs.rs to internal rustdoc references --- doc/choosing_a_combinator.md | 180 ++++++++++++++--------------- doc/upgrading_to_nom_5.md | 6 +- tools/fixup.sh | 218 +++++++++++++++++++++++++++++++++++ 3 files changed, 311 insertions(+), 93 deletions(-) create mode 100755 tools/fixup.sh diff --git a/doc/choosing_a_combinator.md b/doc/choosing_a_combinator.md index dfdee0940..264688d3b 100644 --- a/doc/choosing_a_combinator.md +++ b/doc/choosing_a_combinator.md @@ -10,49 +10,49 @@ Those are used to recognize the lowest level elements of your grammar, like, "he | combinator | usage | input | output | comment | |---|---|---|---|---| -| [char](https://docs.rs/nom/latest/nom/character/complete/fn.char.html) | `char('a')` | `"abc"` | `Ok(("bc", 'a'))` |Matches one character (works with non ASCII chars too) | -| [is_a](https://docs.rs/nom/latest/nom/bytes/complete/fn.is_a.html) | `is_a("ab")` | `"abbac"` | `Ok(("c", "abba"))` |Matches a sequence of any of the characters passed as arguments| -| [is_not](https://docs.rs/nom/latest/nom/bytes/complete/fn.is_not.html) | `is_not("cd")` | `"ababc"` | `Ok(("c", "abab"))` |Matches a sequence of none of the characters passed as arguments| -| [one_of](https://docs.rs/nom/latest/nom/character/complete/fn.one_of.html) | `one_of("abc")` | `"abc"` | `Ok(("bc", 'a'))` |Matches one of the provided characters (works with non ASCII characters too)| -| [none_of](https://docs.rs/nom/latest/nom/character/complete/fn.none_of.html) | `none_of("abc")` | `"xyab"` | `Ok(("yab", 'x'))` |Matches anything but the provided characters| -| [tag](https://docs.rs/nom/latest/nom/bytes/complete/fn.tag.html) | `tag("hello")` | `"hello world"` | `Ok((" world", "hello"))` |Recognizes a specific suite of characters or bytes| -| [tag_no_case](https://docs.rs/nom/latest/nom/bytes/complete/fn.tag_no_case.html) | `tag_no_case("hello")` | `"HeLLo World"` | `Ok((" World", "HeLLo"))` |Case insensitive comparison. Note that case insensitive comparison is not well defined for unicode, and that you might have bad surprises| -| [take](https://docs.rs/nom/latest/nom/bytes/complete/fn.take.html) | `take(4)` | `"hello"` | `Ok(("o", "hell"))` |Takes a specific number of bytes or characters| -| [take_while](https://docs.rs/nom/latest/nom/bytes/complete/fn.take_while.html) | `take_while(is_alphabetic)` | `"abc123"` | `Ok(("123", "abc"))` |Returns the longest list of bytes for which the provided function returns true. `take_while1` does the same, but must return at least one character, while `take_while_m_n` must return between m and n| -| [take_till](https://docs.rs/nom/latest/nom/bytes/complete/fn.take_till.html) | `take_till(is_alphabetic)` | `"123abc"` | `Ok(("abc", "123"))` |Returns the longest list of bytes or characters until the provided function returns true. `take_till1` does the same, but must return at least one character. This is the reverse behaviour from `take_while`: `take_till(f)` is equivalent to `take_while(\|c\| !f(c))`| -| [take_until](https://docs.rs/nom/latest/nom/bytes/complete/fn.take_until.html) | `take_until("world")` | `"Hello world"` | `Ok(("world", "Hello "))` |Returns the longest list of bytes or characters until the provided tag is found. `take_until1` does the same, but must return at least one character| +| [char](crate::character::complete::char) | `char('a')` | `"abc"` | `Ok(("bc", 'a'))` |Matches one character (works with non ASCII chars too) | +| [is_a](crate::bytes::complete::is_a) | `is_a("ab")` | `"abbac"` | `Ok(("c", "abba"))` |Matches a sequence of any of the characters passed as arguments| +| [is_not](crate::bytes::complete::is_not) | `is_not("cd")` | `"ababc"` | `Ok(("c", "abab"))` |Matches a sequence of none of the characters passed as arguments| +| [one_of](crate::character::complete::one_of) | `one_of("abc")` | `"abc"` | `Ok(("bc", 'a'))` |Matches one of the provided characters (works with non ASCII characters too)| +| [none_of](crate::character::complete::none_of) | `none_of("abc")` | `"xyab"` | `Ok(("yab", 'x'))` |Matches anything but the provided characters| +| [tag](crate::bytes::complete::tag) | `tag("hello")` | `"hello world"` | `Ok((" world", "hello"))` |Recognizes a specific suite of characters or bytes| +| [tag_no_case](crate::bytes::complete::tag_no_case) | `tag_no_case("hello")` | `"HeLLo World"` | `Ok((" World", "HeLLo"))` |Case insensitive comparison. Note that case insensitive comparison is not well defined for unicode, and that you might have bad surprises| +| [take](crate::bytes::complete::take) | `take(4)` | `"hello"` | `Ok(("o", "hell"))` |Takes a specific number of bytes or characters| +| [take_while](crate::bytes::complete::take_while) | `take_while(is_alphabetic)` | `"abc123"` | `Ok(("123", "abc"))` |Returns the longest list of bytes for which the provided function returns true. `take_while1` does the same, but must return at least one character, while `take_while_m_n` must return between m and n| +| [take_till](crate::bytes::complete::take_till) | `take_till(is_alphabetic)` | `"123abc"` | `Ok(("abc", "123"))` |Returns the longest list of bytes or characters until the provided function returns true. `take_till1` does the same, but must return at least one character. This is the reverse behaviour from `take_while`: `take_till(f)` is equivalent to `take_while(\|c\| !f(c))`| +| [take_until](crate::bytes::complete::take_until) | `take_until("world")` | `"Hello world"` | `Ok(("world", "Hello "))` |Returns the longest list of bytes or characters until the provided tag is found. `take_until1` does the same, but must return at least one character| ## Choice combinators | combinator | usage | input | output | comment | |---|---|---|---|---| -| [alt](https://docs.rs/nom/latest/nom/branch/fn.alt.html) | `alt((tag("ab"), tag("cd")))` | `"cdef"` | `Ok(("ef", "cd"))` |Try a list of parsers and return the result of the first successful one| -| [permutation](https://docs.rs/nom/latest/nom/branch/fn.permutation.html) | `permutation((tag("ab"), tag("cd"), tag("12")))` | `"cd12abc"` | `Ok(("c", ("ab", "cd", "12"))` |Succeeds when all its child parser have succeeded, whatever the order| +| [alt](crate::branch::alt) | `alt((tag("ab"), tag("cd")))` | `"cdef"` | `Ok(("ef", "cd"))` |Try a list of parsers and return the result of the first successful one| +| [permutation](crate::branch::permutation) | `permutation((tag("ab"), tag("cd"), tag("12")))` | `"cd12abc"` | `Ok(("c", ("ab", "cd", "12"))` |Succeeds when all its child parser have succeeded, whatever the order| ## Sequence combinators | combinator | usage | input | output | comment | |---|---|---|---|---| -| [delimited](https://docs.rs/nom/latest/nom/sequence/fn.delimited.html) | `delimited(char('('), take(2), char(')'))` | `"(ab)cd"` | `Ok(("cd", "ab"))` |Matches an object from the first parser and discards it, then gets an object from the second parser, and finally matches an object from the third parser and discards it.| -| [preceded](https://docs.rs/nom/latest/nom/sequence/fn.preceded.html) | `preceded(tag("ab"), tag("XY"))` | `"abXYZ"` | `Ok(("Z", "XY"))` |Matches an object from the first parser and discards it, then gets an object from the second parser.| -| [terminated](https://docs.rs/nom/latest/nom/sequence/fn.terminated.html) | `terminated(tag("ab"), tag("XY"))` | `"abXYZ"` | `Ok(("Z", "ab"))` |Gets an object from the first parser, then matches an object from the second parser and discards it.| -| [pair](https://docs.rs/nom/latest/nom/sequence/fn.pair.html) | `pair(tag("ab"), tag("XY"))` | `"abXYZ"` | `Ok(("Z", ("ab", "XY")))` |Gets an object from the first parser, then gets another object from the second parser.| -| [separated_pair](https://docs.rs/nom/latest/nom/sequence/fn.separated_pair.html) | `separated_pair(tag("hello"), char(','), tag("world"))` | `"hello,world!"` | `Ok(("!", ("hello", "world")))` |Gets an object from the first parser, then matches an object from the sep_parser and discards it, then gets another object from the second parser.| -| [tuple](https://docs.rs/nom/latest/nom/sequence/fn.tuple.html) | `tuple((tag("ab"), tag("XY"), take(1)))` | `"abXYZ!"` | `Ok(("!", ("ab", "XY", "Z")))` | Chains parsers and assemble the sub results in a tuple. You can use as many child parsers as you can put elements in a tuple| +| [delimited](crate::sequence::delimited) | `delimited(char('('), take(2), char(')'))` | `"(ab)cd"` | `Ok(("cd", "ab"))` |Matches an object from the first parser and discards it, then gets an object from the second parser, and finally matches an object from the third parser and discards it.| +| [preceded](crate::sequence::preceded) | `preceded(tag("ab"), tag("XY"))` | `"abXYZ"` | `Ok(("Z", "XY"))` |Matches an object from the first parser and discards it, then gets an object from the second parser.| +| [terminated](crate::sequence::terminated) | `terminated(tag("ab"), tag("XY"))` | `"abXYZ"` | `Ok(("Z", "ab"))` |Gets an object from the first parser, then matches an object from the second parser and discards it.| +| [pair](crate::sequence::pair) | `pair(tag("ab"), tag("XY"))` | `"abXYZ"` | `Ok(("Z", ("ab", "XY")))` |Gets an object from the first parser, then gets another object from the second parser.| +| [separated_pair](crate::sequence::separated_pair) | `separated_pair(tag("hello"), char(','), tag("world"))` | `"hello,world!"` | `Ok(("!", ("hello", "world")))` |Gets an object from the first parser, then matches an object from the sep_parser and discards it, then gets another object from the second parser.| +| [tuple](crate::sequence::tuple) | `tuple((tag("ab"), tag("XY"), take(1)))` | `"abXYZ!"` | `Ok(("!", ("ab", "XY", "Z")))` | Chains parsers and assemble the sub results in a tuple. You can use as many child parsers as you can put elements in a tuple| ## Applying a parser multiple times | combinator | usage | input | output | comment | |---|---|---|---|---| -| [count](https://docs.rs/nom/latest/nom/multi/fn.count.html) | `count(take(2), 3)` | `"abcdefgh"` | `Ok(("gh", vec!["ab", "cd", "ef"]))` |Applies the child parser a specified number of times| -| [many0](https://docs.rs/nom/latest/nom/multi/fn.many0.html) | `many0(tag("ab"))` | `"abababc"` | `Ok(("c", vec!["ab", "ab", "ab"]))` |Applies the parser 0 or more times and returns the list of results in a Vec. `many1` does the same operation but must return at least one element| -| [many0_count](https://docs.rs/nom/latest/nom/multi/fn.many0_count.html) | `many0_count(tag("ab"))` | `"abababc"` | `Ok(("c", 3))` |Applies the parser 0 or more times and returns how often it was applicable. `many1_count` does the same operation but the parser must apply at least once| -| [many_m_n](https://docs.rs/nom/latest/nom/multi/fn.many_m_n.html) | `many_m_n(1, 3, tag("ab"))` | `"ababc"` | `Ok(("c", vec!["ab", "ab"]))` |Applies the parser between m and n times (n included) and returns the list of results in a Vec| -| [many_till](https://docs.rs/nom/latest/nom/multi/fn.many_till.html) | `many_till(tag( "ab" ), tag( "ef" ))` | `"ababefg"` | `Ok(("g", (vec!["ab", "ab"], "ef")))` |Applies the first parser until the second applies. Returns a tuple containing the list of results from the first in a Vec and the result of the second| -| [separated_list0](https://docs.rs/nom/latest/nom/multi/fn.separated_list0.html) | `separated_list0(tag(","), tag("ab"))` | `"ab,ab,ab."` | `Ok((".", vec!["ab", "ab", "ab"]))` |`separated_list1` works like `separated_list0` but must returns at least one element| -| [fold_many0](https://docs.rs/nom/latest/nom/multi/fn.fold_many0.html) | `fold_many0(be_u8, \|\| 0, \|acc, item\| acc + item)` | `[1, 2, 3]` | `Ok(([], 6))` |Applies the parser 0 or more times and folds the list of return values. The `fold_many1` version must apply the child parser at least one time| -| [fold_many_m_n](https://docs.rs/nom/latest/nom/multi/fn.fold_many_m_n.html) | `fold_many_m_n(1, 2, be_u8, \|\| 0, \|acc, item\| acc + item)` | `[1, 2, 3]` | `Ok(([3], 3))` |Applies the parser between m and n times (n included) and folds the list of return value| -| [length_count](https://docs.rs/nom/latest/nom/multi/fn.length_count.html) | `length_count(number, tag("ab"))` | `"2ababab"` | `Ok(("ab", vec!["ab", "ab"]))` |Gets a number from the first parser, then applies the second parser that many times| +| [count](crate::multi::count) | `count(take(2), 3)` | `"abcdefgh"` | `Ok(("gh", vec!["ab", "cd", "ef"]))` |Applies the child parser a specified number of times| +| [many0](crate::multi::many0) | `many0(tag("ab"))` | `"abababc"` | `Ok(("c", vec!["ab", "ab", "ab"]))` |Applies the parser 0 or more times and returns the list of results in a Vec. `many1` does the same operation but must return at least one element| +| [many0_count](crate::multi::many0_count) | `many0_count(tag("ab"))` | `"abababc"` | `Ok(("c", 3))` |Applies the parser 0 or more times and returns how often it was applicable. `many1_count` does the same operation but the parser must apply at least once| +| [many_m_n](crate::multi::many_m_n) | `many_m_n(1, 3, tag("ab"))` | `"ababc"` | `Ok(("c", vec!["ab", "ab"]))` |Applies the parser between m and n times (n included) and returns the list of results in a Vec| +| [many_till](crate::multi::many_till) | `many_till(tag( "ab" ), tag( "ef" ))` | `"ababefg"` | `Ok(("g", (vec!["ab", "ab"], "ef")))` |Applies the first parser until the second applies. Returns a tuple containing the list of results from the first in a Vec and the result of the second| +| [separated_list0](crate::multi::separated_list0) | `separated_list0(tag(","), tag("ab"))` | `"ab,ab,ab."` | `Ok((".", vec!["ab", "ab", "ab"]))` |`separated_list1` works like `separated_list0` but must returns at least one element| +| [fold_many0](crate::multi::fold_many0) | `fold_many0(be_u8, ::|\| 0, \|acc, item\| acc + item)` | `[1, 2, 3]` | `Ok(([], 6))` |Applies the parser 0 or more times and folds the list of return values. The `fold_many1` version must apply the child parser at least one time| +| [fold_many_m_n](crate::multi::fold_many_m_n) | `fold_many_m_n(1, 2, be_u8, ::|\| 0, \|acc, item\| acc + item)` | `[1, 2, 3]` | `Ok(([3], 3))` |Applies the parser between m and n times (n included) and folds the list of return value| +| [length_count](crate::multi::length_count) | `length_count(number, tag("ab"))` | `"2ababab"` | `Ok(("ab", vec!["ab", "ab"]))` |Gets a number from the first parser, then applies the second parser that many times| ## Integers @@ -60,100 +60,100 @@ Parsing integers from binary formats can be done in two ways: With parser functi The following parsers could be found on [docs.rs number section](https://docs.rs/nom/latest/nom/number/complete/index.html). -- **configurable endianness:** [`i16`](https://docs.rs/nom/latest/nom/number/complete/fn.i16.html), [`i32`](https://docs.rs/nom/latest/nom/number/complete/fn.i32.html), [`i64`](https://docs.rs/nom/latest/nom/number/complete/fn.i64.html), [`u16`](https://docs.rs/nom/latest/nom/number/complete/fn.u16.html), [`u32`](https://docs.rs/nom/latest/nom/number/complete/fn.u32.html), [`u64`](https://docs.rs/nom/latest/nom/number/complete/fn.u64.html) are combinators that take as argument a [`nom::number::Endianness`](https://docs.rs/nom/latest/nom/number/enum.Endianness.html), like this: `i16(endianness)`. If the parameter is `nom::number::Endianness::Big`, parse a big endian `i16` integer, otherwise a little endian `i16` integer. +- **configurable endianness:** [`i16`](crate::number::complete::i16), [`i32`](crate::number::complete::i32), [`i64`](crate::number::complete::i64), [`u16`](crate::number::complete::u16), [`u32`](crate::number::complete::u32), [`u64`](crate::number::complete::u64) are combinators that take as argument a [`nom::number::Endianness`](crate::number::Endianness), like this: `i16(endianness)`. If the parameter is `nom::number::Endianness::Big`, parse a big endian `i16` integer, otherwise a little endian `i16` integer. - **fixed endianness**: The functions are prefixed by `be_` for big endian numbers, and by `le_` for little endian numbers, and the suffix is the type they parse to. As an example, `be_u32` parses a big endian unsigned integer stored in 32 bits. - - [`be_f32`](https://docs.rs/nom/latest/nom/number/complete/fn.be_f32.html), [`be_f64`](https://docs.rs/nom/latest/nom/number/complete/fn.be_f64.html): Big endian floating point numbers - - [`le_f32`](https://docs.rs/nom/latest/nom/number/complete/fn.le_f32.html), [`le_f64`](https://docs.rs/nom/latest/nom/number/complete/fn.le_f64.html): Little endian floating point numbers - - [`be_i8`](https://docs.rs/nom/latest/nom/number/complete/fn.be_i8.html), [`be_i16`](https://docs.rs/nom/latest/nom/number/complete/fn.be_i16.html), [`be_i24`](https://docs.rs/nom/latest/nom/number/complete/fn.be_i24.html), [`be_i32`](https://docs.rs/nom/latest/nom/number/complete/fn.be_i32.html), [`be_i64`](https://docs.rs/nom/latest/nom/number/complete/fn.be_i64.html), [`be_i128`](https://docs.rs/nom/latest/nom/number/complete/fn.be_i128.html): Big endian signed integers - - [`be_u8`](https://docs.rs/nom/latest/nom/number/complete/fn.be_u8.html), [`be_u16`](https://docs.rs/nom/latest/nom/number/complete/fn.be_u16.html), [`be_u24`](https://docs.rs/nom/latest/nom/number/complete/fn.be_u24.html), [`be_u32`](https://docs.rs/nom/latest/nom/number/complete/fn.be_u32.html), [`be_u64`](https://docs.rs/nom/latest/nom/number/complete/fn.be_u64.html), [`be_u128`](https://docs.rs/nom/latest/nom/number/complete/fn.be_u128.html): Big endian unsigned integers - - [`le_i8`](https://docs.rs/nom/latest/nom/number/complete/fn.le_i8.html), [`le_i16`](https://docs.rs/nom/latest/nom/number/complete/fn.le_i16.html), [`le_i24`](https://docs.rs/nom/latest/nom/number/complete/fn.le_i24.html), [`le_i32`](https://docs.rs/nom/latest/nom/number/complete/fn.le_i32.html), [`le_i64`](https://docs.rs/nom/latest/nom/number/complete/fn.le_i64.html), [`le_i128`](https://docs.rs/nom/latest/nom/number/complete/fn.le_i128.html): Little endian signed integers - - [`le_u8`](https://docs.rs/nom/latest/nom/number/complete/fn.le_u8.html), [`le_u16`](https://docs.rs/nom/latest/nom/number/complete/fn.le_u16.html), [`le_u24`](https://docs.rs/nom/latest/nom/number/complete/fn.le_u24.html), [`le_u32`](https://docs.rs/nom/latest/nom/number/complete/fn.le_u32.html), [`le_u64`](https://docs.rs/nom/latest/nom/number/complete/fn.le_u64.html), [`le_u128`](https://docs.rs/nom/latest/nom/number/complete/fn.le_u128.html): Little endian unsigned integers + - [`be_f32`](crate::number::complete::be_f32), [`be_f64`](crate::number::complete::be_f64): Big endian floating point numbers + - [`le_f32`](crate::number::complete::le_f32), [`le_f64`](crate::number::complete::le_f64): Little endian floating point numbers + - [`be_i8`](crate::number::complete::be_i8), [`be_i16`](crate::number::complete::be_i16), [`be_i24`](crate::number::complete::be_i24), [`be_i32`](crate::number::complete::be_i32), [`be_i64`](crate::number::complete::be_i64), [`be_i128`](crate::number::complete::be_i128): Big endian signed integers + - [`be_u8`](crate::number::complete::be_u8), [`be_u16`](crate::number::complete::be_u16), [`be_u24`](crate::number::complete::be_u24), [`be_u32`](crate::number::complete::be_u32), [`be_u64`](crate::number::complete::be_u64), [`be_u128`](crate::number::complete::be_u128): Big endian unsigned integers + - [`le_i8`](crate::number::complete::le_i8), [`le_i16`](crate::number::complete::le_i16), [`le_i24`](crate::number::complete::le_i24), [`le_i32`](crate::number::complete::le_i32), [`le_i64`](crate::number::complete::le_i64), [`le_i128`](crate::number::complete::le_i128): Little endian signed integers + - [`le_u8`](crate::number::complete::le_u8), [`le_u16`](crate::number::complete::le_u16), [`le_u24`](crate::number::complete::le_u24), [`le_u32`](crate::number::complete::le_u32), [`le_u64`](crate::number::complete::le_u64), [`le_u128`](crate::number::complete::le_u128): Little endian unsigned integers ## Streaming related -- [`eof`](https://docs.rs/nom/latest/nom/combinator/fn.eof.html): Returns its input if it is at the end of input data -- [`complete`](https://docs.rs/nom/latest/nom/combinator/fn.complete.html): Replaces an `Incomplete` returned by the child parser with an `Error` +- [`eof`](crate::combinator::eof): Returns its input if it is at the end of input data +- [`complete`](crate::combinator::complete): Replaces an `Incomplete` returned by the child parser with an `Error` ## Modifiers - [`Parser::and`](https://docs.rs/nom/latest/nom/trait.Parser.html#method.and): method to create a parser by applying the supplied parser to the rest of the input after applying `self`, returning their results as a tuple (like `sequence::tuple` but only takes one parser) - [`Parser::and_then`](https://docs.rs/nom/latest/nom/trait.Parser.html#method.and_then): method to create a parser from applying another parser to the output of `self` -- [`map_parser`](https://docs.rs/nom/latest/nom/combinator/fn.map_parser.html): function variant of `Parser::and_then` +- [`map_parser`](crate::combinator::map_parser): function variant of `Parser::and_then` - [`Parser::map`](https://docs.rs/nom/latest/nom/trait.Parser.html#method.map): method to map a function on the output of `self` -- [`map`](https://docs.rs/nom/latest/nom/combinator/fn.map.html): function variant of `Parser::map` +- [`map`](crate::combinator::map): function variant of `Parser::map` - [`Parser::flat_map`](https://docs.rs/nom/latest/nom/trait.Parser.html#method.flat_map): method to create a parser which will map a parser returning function (such as `take` or something which returns a parser) on the output of `self`, then apply that parser over the rest of the input. That is, this method accepts a parser-returning function which consumes the output of `self`, the resulting parser gets applied to the rest of the input -- [`flat_map`](https://docs.rs/nom/latest/nom/combinator/fn.flat_map.html): function variant of `Parser::flat_map` -- [`cond`](https://docs.rs/nom/latest/nom/combinator/fn.cond.html): Conditional combinator. Wraps another parser and calls it if the condition is met -- [`map_opt`](https://docs.rs/nom/latest/nom/combinator/fn.map_opt.html): Maps a function returning an `Option` on the output of a parser -- [`map_res`](https://docs.rs/nom/latest/nom/combinator/fn.map_res.html): Maps a function returning a `Result` on the output of a parser -- [`into`](https://docs.rs/nom/latest/nom/combinator/fn.into.html): Converts the child parser's result to another type -- [`not`](https://docs.rs/nom/latest/nom/combinator/fn.not.html): Returns a result only if the embedded parser returns `Error` or `Incomplete`. Does not consume the input -- [`opt`](https://docs.rs/nom/latest/nom/combinator/fn.opt.html): Make the underlying parser optional -- [`cut`](https://docs.rs/nom/latest/nom/combinator/fn.cut.html): Transform recoverable error into unrecoverable failure (commitment to current branch) -- [`peek`](https://docs.rs/nom/latest/nom/combinator/fn.peek.html): Returns a result without consuming the input -- [`recognize`](https://docs.rs/nom/latest/nom/combinator/fn.recognize.html): If the child parser was successful, return the consumed input as the produced value -- [`consumed`](https://docs.rs/nom/latest/nom/combinator/fn.consumed.html): If the child parser was successful, return a tuple of the consumed input and the produced output. -- [`verify`](https://docs.rs/nom/latest/nom/combinator/fn.verify.html): Returns the result of the child parser if it satisfies a verification function -- [`value`](https://docs.rs/nom/latest/nom/combinator/fn.value.html): Returns a provided value if the child parser was successful -- [`all_consuming`](https://docs.rs/nom/latest/nom/combinator/fn.all_consuming.html): Returns the result of the child parser only if it consumed all the input +- [`flat_map`](crate::combinator::flat_map): function variant of `Parser::flat_map` +- [`cond`](crate::combinator::cond): Conditional combinator. Wraps another parser and calls it if the condition is met +- [`map_opt`](crate::combinator::map_opt): Maps a function returning an `Option` on the output of a parser +- [`map_res`](crate::combinator::map_res): Maps a function returning a `Result` on the output of a parser +- [`into`](crate::combinator::into): Converts the child parser's result to another type +- [`not`](crate::combinator::not): Returns a result only if the embedded parser returns `Error` or `Incomplete`. Does not consume the input +- [`opt`](crate::combinator::opt): Make the underlying parser optional +- [`cut`](crate::combinator::cut): Transform recoverable error into unrecoverable failure (commitment to current branch) +- [`peek`](crate::combinator::peek): Returns a result without consuming the input +- [`recognize`](crate::combinator::recognize): If the child parser was successful, return the consumed input as the produced value +- [`consumed`](crate::combinator::consumed): If the child parser was successful, return a tuple of the consumed input and the produced output. +- [`verify`](crate::combinator::verify): Returns the result of the child parser if it satisfies a verification function +- [`value`](crate::combinator::value): Returns a provided value if the child parser was successful +- [`all_consuming`](crate::combinator::all_consuming): Returns the result of the child parser only if it consumed all the input ## Error management and debugging -- [`dbg_dmp`](https://docs.rs/nom/latest/nom/fn.dbg_dmp.html): Prints a message and the input if the parser fails +- [`dbg_dmp`](crate::dbg_dmp): Prints a message and the input if the parser fails ## Text parsing -- [`escaped`](https://docs.rs/nom/latest/nom/bytes/complete/fn.escaped.html): Matches a byte string with escaped characters -- [`escaped_transform`](https://docs.rs/nom/latest/nom/bytes/complete/fn.escaped_transform.html): Matches a byte string with escaped characters, and returns a new string with the escaped characters replaced -- [`precedence`](https://docs.rs/nom/latest/nom/precedence/fn.precedence.html): Parses an expression with regards to operator precedence +- [`escaped`](crate::bytes::complete::escaped): Matches a byte string with escaped characters +- [`escaped_transform`](crate::bytes::complete::escaped_transform): Matches a byte string with escaped characters, and returns a new string with the escaped characters replaced +- [`precedence`](crate::precedence::precedence): Parses an expression with regards to operator precedence ## Binary format parsing -- [`length_data`](https://docs.rs/nom/latest/nom/multi/fn.length_data.html): Gets a number from the first parser, then takes a subslice of the input of that size, and returns that subslice -- [`length_value`](https://docs.rs/nom/latest/nom/multi/fn.length_value.html): Gets a number from the first parser, takes a subslice of the input of that size, then applies the second parser on that subslice. If the second parser returns `Incomplete`, `length_value` will return an error +- [`length_data`](crate::multi::length_data): Gets a number from the first parser, then takes a subslice of the input of that size, and returns that subslice +- [`length_value`](crate::multi::length_value): Gets a number from the first parser, takes a subslice of the input of that size, then applies the second parser on that subslice. If the second parser returns `Incomplete`, `length_value` will return an error ## Bit stream parsing -- [`bits`](https://docs.rs/nom/latest/nom/bits/fn.bits.html): Transforms the current input type (byte slice `&[u8]`) to a bit stream on which bit specific parsers and more general combinators can be applied -- [`bytes`](https://docs.rs/nom/latest/nom/bits/fn.bytes.html): Transforms its bits stream input back into a byte slice for the underlying parser +- [`bits`](crate::bits::bits): Transforms the current input type (byte slice `&[u8]`) to a bit stream on which bit specific parsers and more general combinators can be applied +- [`bytes`](crate::bits::bytes): Transforms its bits stream input back into a byte slice for the underlying parser ## Remaining combinators -- [`success`](https://docs.rs/nom/latest/nom/combinator/fn.success.html): Returns a value without consuming any input, always succeeds -- [`fail`](https://docs.rs/nom/latest/nom/combinator/fn.fail.html): Inversion of `success`. Always fails. +- [`success`](crate::combinator::success): Returns a value without consuming any input, always succeeds +- [`fail`](crate::combinator::fail): Inversion of `success`. Always fails. ## Character test functions Use these functions with a combinator like `take_while`: -- [`is_alphabetic`](https://docs.rs/nom/latest/nom/character/fn.is_alphabetic.html): Tests if byte is ASCII alphabetic: `[A-Za-z]` -- [`is_alphanumeric`](https://docs.rs/nom/latest/nom/character/fn.is_alphanumeric.html): Tests if byte is ASCII alphanumeric: `[A-Za-z0-9]` -- [`is_digit`](https://docs.rs/nom/latest/nom/character/fn.is_digit.html): Tests if byte is ASCII digit: `[0-9]` -- [`is_hex_digit`](https://docs.rs/nom/latest/nom/character/fn.is_hex_digit.html): Tests if byte is ASCII hex digit: `[0-9A-Fa-f]` -- [`is_oct_digit`](https://docs.rs/nom/latest/nom/character/fn.is_oct_digit.html): Tests if byte is ASCII octal digit: `[0-7]` -- [`is_bin_digit`](https://docs.rs/nom/latest/nom/character/fn.is_bin_digit.html): Tests if byte is ASCII binary digit: `[0-1]` -- [`is_space`](https://docs.rs/nom/latest/nom/character/fn.is_space.html): Tests if byte is ASCII space or tab: `[ \t]` -- [`is_newline`](https://docs.rs/nom/latest/nom/character/fn.is_newline.html): Tests if byte is ASCII newline: `[\n]` +- [`is_alphabetic`](crate::character::is_alphabetic): Tests if byte is ASCII alphabetic: `[A-Za-z]` +- [`is_alphanumeric`](crate::character::is_alphanumeric): Tests if byte is ASCII alphanumeric: `[A-Za-z0-9]` +- [`is_digit`](crate::character::is_digit): Tests if byte is ASCII digit: `[0-9]` +- [`is_hex_digit`](crate::character::is_hex_digit): Tests if byte is ASCII hex digit: `[0-9A-Fa-f]` +- [`is_oct_digit`](crate::character::is_oct_digit): Tests if byte is ASCII octal digit: `[0-7]` +- [`is_bin_digit`](crate::character::is_bin_digit): Tests if byte is ASCII binary digit: `[0-1]` +- [`is_space`](crate::character::is_space): Tests if byte is ASCII space or tab: `[ \t]` +- [`is_newline`](crate::character::is_newline): Tests if byte is ASCII newline: `[\n]` Alternatively there are ready to use functions: -- [`alpha0`](https://docs.rs/nom/latest/nom/character/complete/fn.alpha0.html): Recognizes zero or more lowercase and uppercase alphabetic characters: `[a-zA-Z]`. [`alpha1`](https://docs.rs/nom/latest/nom/character/complete/fn.alpha1.html) does the same but returns at least one character -- [`alphanumeric0`](https://docs.rs/nom/latest/nom/character/complete/fn.alphanumeric0.html): Recognizes zero or more numerical and alphabetic characters: `[0-9a-zA-Z]`. [`alphanumeric1`](https://docs.rs/nom/latest/nom/character/complete/fn.alphanumeric1.html) does the same but returns at least one character -- [`anychar`](https://docs.rs/nom/latest/nom/character/complete/fn.anychar.html): Matches one byte as a character -- [`crlf`](https://docs.rs/nom/latest/nom/character/complete/fn.crlf.html): Recognizes the string `\r\n` -- [`digit0`](https://docs.rs/nom/latest/nom/character/complete/fn.digit0.html): Recognizes zero or more numerical characters: `[0-9]`. [`digit1`](https://docs.rs/nom/latest/nom/character/complete/fn.digit1.html) does the same but returns at least one character -- [`double`](https://docs.rs/nom/latest/nom/number/complete/fn.double.html): Recognizes floating point number in a byte string and returns a `f64` -- [`float`](https://docs.rs/nom/latest/nom/number/complete/fn.float.html): Recognizes floating point number in a byte string and returns a `f32` -- [`hex_digit0`](https://docs.rs/nom/latest/nom/character/complete/fn.hex_digit0.html): Recognizes zero or more hexadecimal numerical characters: `[0-9A-Fa-f]`. [`hex_digit1`](https://docs.rs/nom/latest/nom/character/complete/fn.hex_digit1.html) does the same but returns at least one character -- [`hex_u32`](https://docs.rs/nom/latest/nom/number/complete/fn.hex_u32.html): Recognizes a hex-encoded integer -- [`line_ending`](https://docs.rs/nom/latest/nom/character/complete/fn.line_ending.html): Recognizes an end of line (both `\n` and `\r\n`) -- [`multispace0`](https://docs.rs/nom/latest/nom/character/complete/fn.multispace0.html): Recognizes zero or more spaces, tabs, carriage returns and line feeds. [`multispace1`](https://docs.rs/nom/latest/nom/character/complete/fn.multispace1.html) does the same but returns at least one character -- [`newline`](https://docs.rs/nom/latest/nom/character/complete/fn.newline.html): Matches a newline character `\n` -- [`not_line_ending`](https://docs.rs/nom/latest/nom/character/complete/fn.not_line_ending.html): Recognizes a string of any char except `\r` or `\n` -- [`oct_digit0`](https://docs.rs/nom/latest/nom/character/complete/fn.oct_digit0.html): Recognizes zero or more octal characters: `[0-7]`. [`oct_digit1`](https://docs.rs/nom/latest/nom/character/complete/fn.oct_digit1.html) does the same but returns at least one character -- [`bin_digit0`](https://docs.rs/nom/latest/nom/character/complete/fn.bin_digit0.html): Recognizes zero or more binary characters: `[0-1]`. [`bin_digit1`](https://docs.rs/nom/latest/nom/character/complete/fn.bin_digit1.html) does the same but returns at least one character -- [`rest`](https://docs.rs/nom/latest/nom/combinator/fn.rest.html): Return the remaining input -- [`rest_len`](https://docs.rs/nom/latest/nom/combinator/fn.rest_len.html): Return the length of the remaining input -- [`space0`](https://docs.rs/nom/latest/nom/character/complete/fn.space0.html): Recognizes zero or more spaces and tabs. [`space1`](https://docs.rs/nom/latest/nom/character/complete/fn.space1.html) does the same but returns at least one character -- [`tab`](https://docs.rs/nom/latest/nom/character/complete/fn.tab.html): Matches a tab character `\t` +- [`alpha0`](crate::character::complete::alpha0): Recognizes zero or more lowercase and uppercase alphabetic characters: `[a-zA-Z]`. [`alpha1`](crate::character::complete::alpha1) does the same but returns at least one character +- [`alphanumeric0`](crate::character::complete::alphanumeric0): Recognizes zero or more numerical and alphabetic characters: `[0-9a-zA-Z]`. [`alphanumeric1`](crate::character::complete::alphanumeric1) does the same but returns at least one character +- [`anychar`](crate::character::complete::anychar): Matches one byte as a character +- [`crlf`](crate::character::complete::crlf): Recognizes the string `\r\n` +- [`digit0`](crate::character::complete::digit0): Recognizes zero or more numerical characters: `[0-9]`. [`digit1`](crate::character::complete::digit1) does the same but returns at least one character +- [`double`](crate::number::complete::double): Recognizes floating point number in a byte string and returns a `f64` +- [`float`](crate::number::complete::float): Recognizes floating point number in a byte string and returns a `f32` +- [`hex_digit0`](crate::character::complete::hex_digit0): Recognizes zero or more hexadecimal numerical characters: `[0-9A-Fa-f]`. [`hex_digit1`](crate::character::complete::hex_digit1) does the same but returns at least one character +- [`hex_u32`](crate::number::complete::hex_u32): Recognizes a hex-encoded integer +- [`line_ending`](crate::character::complete::line_ending): Recognizes an end of line (both `\n` and `\r\n`) +- [`multispace0`](crate::character::complete::multispace0): Recognizes zero or more spaces, tabs, carriage returns and line feeds. [`multispace1`](crate::character::complete::multispace1) does the same but returns at least one character +- [`newline`](crate::character::complete::newline): Matches a newline character `\n` +- [`not_line_ending`](crate::character::complete::not_line_ending): Recognizes a string of any char except `\r` or `\n` +- [`oct_digit0`](crate::character::complete::oct_digit0): Recognizes zero or more octal characters: `[0-7]`. [`oct_digit1`](crate::character::complete::oct_digit1) does the same but returns at least one character +- [`bin_digit0`](crate::character::complete::bin_digit0): Recognizes zero or more binary characters: `[0-1]`. [`bin_digit1`](crate::character::complete::bin_digit1) does the same but returns at least one character +- [`rest`](crate::combinator::rest): Return the remaining input +- [`rest_len`](crate::combinator::rest_len): Return the length of the remaining input +- [`space0`](crate::character::complete::space0): Recognizes zero or more spaces and tabs. [`space1`](crate::character::complete::space1) does the same but returns at least one character +- [`tab`](crate::character::complete::tab): Matches a tab character `\t` diff --git a/doc/upgrading_to_nom_5.md b/doc/upgrading_to_nom_5.md index 421eb6711..77398423b 100644 --- a/doc/upgrading_to_nom_5.md +++ b/doc/upgrading_to_nom_5.md @@ -46,11 +46,11 @@ pub enum Err { Now the error type is completely generic, so you can choose exactly what you need, from erasing errors entirely, to reproducing the -`verbose-errors` feature with the [`VerboseError` type](https://docs.rs/nom/latest/nom/error/struct.VerboseError.html). -The [`ErrorKind` enum](https://docs.rs/nom/latest/nom/error/enum.ErrorKind.html) +`verbose-errors` feature with the [`VerboseError` type](crate::error::VerboseError). +The [`ErrorKind` enum](crate::error::ErrorKind) is not generic now: It does not need to hold a custom error type. -Any error type has to implement the [`ParseError` trait](https://docs.rs/nom/latest/nom/error/trait.ParseError.html) +Any error type has to implement the [`ParseError` trait](crate::error::ParseError) that specifies methods to build an error from a position in input data, and an `ErrorKind`, or another error, etc. diff --git a/tools/fixup.sh b/tools/fixup.sh new file mode 100755 index 000000000..681b4d0c2 --- /dev/null +++ b/tools/fixup.sh @@ -0,0 +1,218 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2004,SC2206,SC2068,SC2086 + +set -e +set -o pipefail +set -o noglob +set -u +export IFS=$'\n' + +script_name="$(basename "${BASH_SOURCE[0]}")" +script_path="$(2>/dev/random 1>/dev/random cd $(dirname "${BASH_SOURCE[0]}") && pwd)" +this_script_path="${script_path}/${script_name}" + +declare -a argv=($@) +declare argc=${#argv[@]} + +declare -a regular_file_argv=() + +declare -i regular_file_argv_count=0 +declare -A sed_fixup_commands_by_regex=() +declare -a sed_regexp_keys=() + +declare -A sed_failures=() +declare -A diff_failures=() +declare -A success=() + +register_sed_regexp_and_command() { + local -a reg_argv=($@) + local -i reg_argv_count=${#reg_argv[@]} + if [ ${reg_argv_count} -ne 2 ]; then + exit_error "register_sed_regexp_and_command takes exactly 2 arguments but received ${reg_argv_count} instead" + fi + local -- sed_regexp="$1" + shift + local -- sed_command="$1" + shift + if [ -z "${sed_regexp}" ]; then + exit_error "register_sed_regexp_and_command first argument argument (sed_regexp) cannot be empty" + fi + if [ -z "${sed_command}" ]; then + exit_error "register_sed_command_and_command last argument argument (sed_command) cannot be empty" + fi + sed_fixup_commands_by_regex+=(["${sed_regexp}"]=$(eval "echo \"${sed_command}\"")) + sed_regexp_keys=(${!sed_fixup_commands_by_regex[@]}) +} + +register_sed_regexp_and_command \ + "(https[:]\/\/docs[.]rs[\/]nom[\/]latest[\/]nom[\/]\([^[:space:]]\+\)[\/]\(fn\|trait\|enum\|struct\|static\|const\)[.]\([a-zA-Z0-9_]\+\)[.]html)" \ + 's/${sed_regexp}/(crate::\1::\3)/g' + +register_sed_regexp_and_command \ + "(https[:]\/\/docs[.]rs[\/]nom[\/]latest[\/]nom[\/]\(fn\|trait\|enum\|struct\|static\|const\)[.]\([a-zA-Z0-9_]\+\)[.]html)" \ + 's/${sed_regexp}/(crate::\2)/g' + +register_sed_regexp_and_command \ + "(crate::\([^\/]\+\)[\/]\([^)]\+\))" \ + 's/${sed_regexp}/(crate::\1::\2)/g' + +error_prefix_color_rgb="$((0xFF));$((0x00));$((0x42))" +error_color_rgb="$((0xFF));$((0x32));$((0x32))" +error_color_rgb="$((0xFF));$((0x3E));$((0x5C))" +warn_prefix_color_rgb="$((0xFF));$((0x6A));$((0x32))" +warn_color_rgb="$((0xFF));$((0xA1));$((0x32))" + +on_exit() { + repl sane +} +on_ctrlc() { + repl no echo + 1>&2 echo -e "\x1b[1;38;2;${error_color_rgb}m\rAborted with Ctrl-C\x1b[0m" + repl sane + exit 101 +} +trap on_exit exit +trap on_ctrlc hup +trap on_ctrlc int +trap on_ctrlc emt +trap on_ctrlc bus +trap on_ctrlc segv +trap on_ctrlc sys + +repl() { + local -a stty_args=() + case "$1" in -*no*stdin | no*stdin | -*no*echo | no*echo | capture) args+=('-echo') ;; *) args+=('sane') ;; esac + 2>/dev/random 1>/dev/random stty ${stty_args[@]} +} +usage() { + repl no echo + 1>&2 echo -e "$(basename $0) [...]" + repl sane +} +exit_error() { + error "${@}" + exit 101 +} +warn_prefixed() { + local -- prefix="$1" + shift + local -- message="$@" + 1>&2 echo -e "\x1b[1;38;2;${warn_prefix_color_rgb}m[${prefix}]\x1b[1;38;2;${warn_color_rgb}m\n${message}\x1b[0m" +} +warn() { + warn_prefixed "[${script_name} warn]" "${@}" +} + +error() { + error_prefixed "[${script_name} error]" "${@}" +} +error_prefixed() { + local -- prefix="$1" + shift + local -- message="$@" + 1>&2 echo -e "\x1b[1;38;2;${error_prefix_color_rgb}m[${prefix}]\x1b[1;38;2;${error_color_rgb}m\n${message}\x1b[0m" +} + +process_argv() { + repl no echo + if [ ${argc} -eq 0 ]; then + exit_error "missing argument(s): " + exit 101 + fi + for index in ${!argv[@]}; do + current=$(($index + 1)) + arg="${argv[$index]}" + if [ -f "${arg}" ]; then + regular_file_argv+=("${arg}") + else + exit_error "invalid argument (${current}/${regular_file_argv_count}), not an existing file: ${arg@Q}" + fi + done + regular_file_argv_count=${#regular_file_argv[@]} + repl sane +} + +fixup_markdown_file() { + markdown_path="$1" + + if [ -z "${markdown_path}" ]; then + exit_error "[in function fixup_markdown_file] missing argument " + fi + local -i index=0 + local -- current="" + local -- progress="" + local -i sed_regexp_count=${#sed_regexp_keys[@]} + local -i exit_code=0 + + # ICAgICMgXDMuXDYKICAgICMgc2VkX3JlZ2V4cD0iaHR0cHNbOl1cL1wvZG9jc1suXXJzXC9ub21cL1wobGF0ZXN0XC9ub21cL1wpXD9cKFwoW15cL11cK1wpW1wvXVwpXCtcKFwoZm5cfHRyYWl0XHxlbnVtXHxzdHJ1Y3RcfHN0YXRpY1x8Y29uc3RcKVsuXVwpXChbYS16QS1aMC05X11cK1wpWy5daHRtbCIKICAgICMgc2VkX2NvbW1hbmQ9InMvJHtzZWRfcmVnZXhwfS9jcmF0ZTo6XDMuXDYvZyIK + # | [AsBytes](https://docs.rs/nom/latest/nom/trait.AsBytes.html) + # | [AsBytes](crate::latest/nom/trait.AsBytes.html) + for index in ${!sed_regexp_keys[@]}; do + current=$(($index + 1)) + progress="[${current}/${sed_regexp_count}]" + + sed_regexp="${sed_regexp_keys[${index}]}" + sed_command=${sed_fixup_commands_by_regex["${sed_regexp}"]} + + # 1>&2 echo "sed ${sed_command@Q} -i ${markdown_path@Q}" + + mod_file=$(mktemp) + diff_stderr=$(mktemp) + sed_stderr=$(mktemp) + local -- sed_call="sed \"${sed_command}\" \"${markdown_path}\"" + if 2>${sed_stderr} sed "${sed_command}" "${markdown_path}" >${mod_file}; then + rm -f "${sed_stderr}" + if ! diff=$(2>${diff_stderr} diff -u --color=always "${markdown_path}" "${mod_file}"); then + success+=("${progress} ${sed_call}") + mv -f "${mod_file}" "${markdown_path}" + else + diff_failures+=(["${progress} ${sed_call}"]="${diff}") + rm -f "${mod_file}" + warn_prefixed "[sed warning]" " nothing changed in ${markdown_path@Q}" + return 1 + fi + else + exit_code=$? + sed_error="$(cat "${sed_stderr}")" + sed_failures+=(["${progress} ${sed_call}"]="${sed_error}") + warn_prefixed "[sed failed]" "\n${sed_error}" + return ${exit_code} + fi + done +} +main() { + local -i index=0 + local -i current=0 + local -- param="" + local -- progress="" + local -i exit_code=0 + local -- filename="" + local -A fix_failures=() + for index in ${!regular_file_argv[@]}; do + current=$(($index + 1)) + progress="[${index}/${regular_file_argv_count}]" + param="${regular_file_argv[$index]}" + if fixup_markdown_file "${param}"; then + 1>&2 echo -e "fixed ${param@Q}" + else + exit_code=$? + fix_failures+=(["${param}"]=${exit_code}) + fi + done + local -i fix_failures_count=${#fix_failures[@]} + if [ ${fix_failures_count} -eq 0 ]; then + exit 0 + fi + for filename in ${!fix_failures[@]}; do + exit_code=${fix_failures[${filename}]}; + error_prefixed "error ${exit_code}" "${filename}" + done +} + +if [ "${0}" == "${BASH_SOURCE[0]}" ]; then + process_argv ${argv[@]} + main +else + 1>&2 echo -e "${BASH_SOURCE[0]} appears to being used as a library by ${0@Q}" +fi +repl sane From e3213a091258d717bcbf62954770d4c2284dd5a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Falc=C3=A3o?= Date: Sun, 26 Oct 2025 02:41:05 +0000 Subject: [PATCH 6/8] deletes no longer needed script --- tools/fixup.sh | 218 ------------------------------------------------- 1 file changed, 218 deletions(-) delete mode 100755 tools/fixup.sh diff --git a/tools/fixup.sh b/tools/fixup.sh deleted file mode 100755 index 681b4d0c2..000000000 --- a/tools/fixup.sh +++ /dev/null @@ -1,218 +0,0 @@ -#!/usr/bin/env bash -# shellcheck disable=SC2004,SC2206,SC2068,SC2086 - -set -e -set -o pipefail -set -o noglob -set -u -export IFS=$'\n' - -script_name="$(basename "${BASH_SOURCE[0]}")" -script_path="$(2>/dev/random 1>/dev/random cd $(dirname "${BASH_SOURCE[0]}") && pwd)" -this_script_path="${script_path}/${script_name}" - -declare -a argv=($@) -declare argc=${#argv[@]} - -declare -a regular_file_argv=() - -declare -i regular_file_argv_count=0 -declare -A sed_fixup_commands_by_regex=() -declare -a sed_regexp_keys=() - -declare -A sed_failures=() -declare -A diff_failures=() -declare -A success=() - -register_sed_regexp_and_command() { - local -a reg_argv=($@) - local -i reg_argv_count=${#reg_argv[@]} - if [ ${reg_argv_count} -ne 2 ]; then - exit_error "register_sed_regexp_and_command takes exactly 2 arguments but received ${reg_argv_count} instead" - fi - local -- sed_regexp="$1" - shift - local -- sed_command="$1" - shift - if [ -z "${sed_regexp}" ]; then - exit_error "register_sed_regexp_and_command first argument argument (sed_regexp) cannot be empty" - fi - if [ -z "${sed_command}" ]; then - exit_error "register_sed_command_and_command last argument argument (sed_command) cannot be empty" - fi - sed_fixup_commands_by_regex+=(["${sed_regexp}"]=$(eval "echo \"${sed_command}\"")) - sed_regexp_keys=(${!sed_fixup_commands_by_regex[@]}) -} - -register_sed_regexp_and_command \ - "(https[:]\/\/docs[.]rs[\/]nom[\/]latest[\/]nom[\/]\([^[:space:]]\+\)[\/]\(fn\|trait\|enum\|struct\|static\|const\)[.]\([a-zA-Z0-9_]\+\)[.]html)" \ - 's/${sed_regexp}/(crate::\1::\3)/g' - -register_sed_regexp_and_command \ - "(https[:]\/\/docs[.]rs[\/]nom[\/]latest[\/]nom[\/]\(fn\|trait\|enum\|struct\|static\|const\)[.]\([a-zA-Z0-9_]\+\)[.]html)" \ - 's/${sed_regexp}/(crate::\2)/g' - -register_sed_regexp_and_command \ - "(crate::\([^\/]\+\)[\/]\([^)]\+\))" \ - 's/${sed_regexp}/(crate::\1::\2)/g' - -error_prefix_color_rgb="$((0xFF));$((0x00));$((0x42))" -error_color_rgb="$((0xFF));$((0x32));$((0x32))" -error_color_rgb="$((0xFF));$((0x3E));$((0x5C))" -warn_prefix_color_rgb="$((0xFF));$((0x6A));$((0x32))" -warn_color_rgb="$((0xFF));$((0xA1));$((0x32))" - -on_exit() { - repl sane -} -on_ctrlc() { - repl no echo - 1>&2 echo -e "\x1b[1;38;2;${error_color_rgb}m\rAborted with Ctrl-C\x1b[0m" - repl sane - exit 101 -} -trap on_exit exit -trap on_ctrlc hup -trap on_ctrlc int -trap on_ctrlc emt -trap on_ctrlc bus -trap on_ctrlc segv -trap on_ctrlc sys - -repl() { - local -a stty_args=() - case "$1" in -*no*stdin | no*stdin | -*no*echo | no*echo | capture) args+=('-echo') ;; *) args+=('sane') ;; esac - 2>/dev/random 1>/dev/random stty ${stty_args[@]} -} -usage() { - repl no echo - 1>&2 echo -e "$(basename $0) [...]" - repl sane -} -exit_error() { - error "${@}" - exit 101 -} -warn_prefixed() { - local -- prefix="$1" - shift - local -- message="$@" - 1>&2 echo -e "\x1b[1;38;2;${warn_prefix_color_rgb}m[${prefix}]\x1b[1;38;2;${warn_color_rgb}m\n${message}\x1b[0m" -} -warn() { - warn_prefixed "[${script_name} warn]" "${@}" -} - -error() { - error_prefixed "[${script_name} error]" "${@}" -} -error_prefixed() { - local -- prefix="$1" - shift - local -- message="$@" - 1>&2 echo -e "\x1b[1;38;2;${error_prefix_color_rgb}m[${prefix}]\x1b[1;38;2;${error_color_rgb}m\n${message}\x1b[0m" -} - -process_argv() { - repl no echo - if [ ${argc} -eq 0 ]; then - exit_error "missing argument(s): " - exit 101 - fi - for index in ${!argv[@]}; do - current=$(($index + 1)) - arg="${argv[$index]}" - if [ -f "${arg}" ]; then - regular_file_argv+=("${arg}") - else - exit_error "invalid argument (${current}/${regular_file_argv_count}), not an existing file: ${arg@Q}" - fi - done - regular_file_argv_count=${#regular_file_argv[@]} - repl sane -} - -fixup_markdown_file() { - markdown_path="$1" - - if [ -z "${markdown_path}" ]; then - exit_error "[in function fixup_markdown_file] missing argument " - fi - local -i index=0 - local -- current="" - local -- progress="" - local -i sed_regexp_count=${#sed_regexp_keys[@]} - local -i exit_code=0 - - # ICAgICMgXDMuXDYKICAgICMgc2VkX3JlZ2V4cD0iaHR0cHNbOl1cL1wvZG9jc1suXXJzXC9ub21cL1wobGF0ZXN0XC9ub21cL1wpXD9cKFwoW15cL11cK1wpW1wvXVwpXCtcKFwoZm5cfHRyYWl0XHxlbnVtXHxzdHJ1Y3RcfHN0YXRpY1x8Y29uc3RcKVsuXVwpXChbYS16QS1aMC05X11cK1wpWy5daHRtbCIKICAgICMgc2VkX2NvbW1hbmQ9InMvJHtzZWRfcmVnZXhwfS9jcmF0ZTo6XDMuXDYvZyIK - # | [AsBytes](https://docs.rs/nom/latest/nom/trait.AsBytes.html) - # | [AsBytes](crate::latest/nom/trait.AsBytes.html) - for index in ${!sed_regexp_keys[@]}; do - current=$(($index + 1)) - progress="[${current}/${sed_regexp_count}]" - - sed_regexp="${sed_regexp_keys[${index}]}" - sed_command=${sed_fixup_commands_by_regex["${sed_regexp}"]} - - # 1>&2 echo "sed ${sed_command@Q} -i ${markdown_path@Q}" - - mod_file=$(mktemp) - diff_stderr=$(mktemp) - sed_stderr=$(mktemp) - local -- sed_call="sed \"${sed_command}\" \"${markdown_path}\"" - if 2>${sed_stderr} sed "${sed_command}" "${markdown_path}" >${mod_file}; then - rm -f "${sed_stderr}" - if ! diff=$(2>${diff_stderr} diff -u --color=always "${markdown_path}" "${mod_file}"); then - success+=("${progress} ${sed_call}") - mv -f "${mod_file}" "${markdown_path}" - else - diff_failures+=(["${progress} ${sed_call}"]="${diff}") - rm -f "${mod_file}" - warn_prefixed "[sed warning]" " nothing changed in ${markdown_path@Q}" - return 1 - fi - else - exit_code=$? - sed_error="$(cat "${sed_stderr}")" - sed_failures+=(["${progress} ${sed_call}"]="${sed_error}") - warn_prefixed "[sed failed]" "\n${sed_error}" - return ${exit_code} - fi - done -} -main() { - local -i index=0 - local -i current=0 - local -- param="" - local -- progress="" - local -i exit_code=0 - local -- filename="" - local -A fix_failures=() - for index in ${!regular_file_argv[@]}; do - current=$(($index + 1)) - progress="[${index}/${regular_file_argv_count}]" - param="${regular_file_argv[$index]}" - if fixup_markdown_file "${param}"; then - 1>&2 echo -e "fixed ${param@Q}" - else - exit_code=$? - fix_failures+=(["${param}"]=${exit_code}) - fi - done - local -i fix_failures_count=${#fix_failures[@]} - if [ ${fix_failures_count} -eq 0 ]; then - exit 0 - fi - for filename in ${!fix_failures[@]}; do - exit_code=${fix_failures[${filename}]}; - error_prefixed "error ${exit_code}" "${filename}" - done -} - -if [ "${0}" == "${BASH_SOURCE[0]}" ]; then - process_argv ${argv[@]} - main -else - 1>&2 echo -e "${BASH_SOURCE[0]} appears to being used as a library by ${0@Q}" -fi -repl sane From a96671e6a474615d18b903cce6e2ef90d5cf0aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Falc=C3=A3o?= Date: Sun, 26 Oct 2025 02:42:49 +0000 Subject: [PATCH 7/8] restore rustfmt to commit 51c3c4e44fa78a8a09b413419372b97b2cc2a787 --- rustfmt.toml | 80 ++-------------------------------------------------- 1 file changed, 2 insertions(+), 78 deletions(-) diff --git a/rustfmt.toml b/rustfmt.toml index fd283ca26..346c9d288 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,78 +1,2 @@ -# ignore = [] # Skip formatting the specified files and directories -# verbose = "Quiet" # How much to information to emit to the user (Verbose, Normal, Quiet) -array_width = 42 # Maximum width of an array literal before falling back to vertical formatting. -attr_fn_like_width = 20 # Maximum width of the args of a function-like attributes before falling back to vertical formatting. -chain_width = 50 # Maximum length of a chain to fit on a single line. -comment_width = 80 # Maximum length of comments. No effect unless wrap_comments = true -doc_comment_code_block_width = 100 # Maximum width for code snippets in doc comments. No effect unless format_code_in_doc_comments = true -fn_call_width = 57 # Maximum width of the args of a function call before falling back to vertical formatting. -inline_attribute_width = 0 # Write an item and its attribute on the same line if their combined width is below a threshold -max_width = 80 # Maximum width of each line -short_array_element_width_threshold = 10# Width threshold for an array element to be considered short -single_line_if_else_max_width = 20 # Maximum line length for single line if-else expressions. A value of zero means always break if-else expressions. -single_line_let_else_max_width = 20 # Maximum line length for single line let-else statements. A value of zero means always format the divergent `else` block over multiple lines. -struct_lit_width = 18 # Maximum width in the body of a struct lit before falling back to vertical formatting. -struct_variant_width = 35 # Maximum width in the body of a struct variant before falling back to vertical formatting. -binop_separator = "Front" # Where to put a binary operator when a binary expression goes multiline -blank_lines_lower_bound = 0 # Minimum number of blank lines which must be put between items -blank_lines_upper_bound = 1 # Maximum number of blank lines which can be put between items -brace_style = "SameLineWhere" # Brace style for items -color = "Auto" # What Color option to use when none is supplied = Always, Never, Auto -combine_control_expr = true # Combine control expressions with function calls -condense_wildcard_suffixes = false # Replace strings of _ wildcards by a single .. in tuple patterns -control_brace_style = "AlwaysSameLine" # Brace style for control flow constructs -disable_all_formatting = false # Don't reformat anything -edition = "2021" # The edition of the parser (RFC 2052) -emit_mode = "Files" # What emit Mode to use when none is supplied -empty_item_single_line = true # Put empty-body functions and impls on a single line -enum_discrim_align_threshold = 0 # Align enum variants discrims, if their diffs fit within threshold -error_on_line_overflow = false # Error if unable to get all lines within max_width -error_on_unformatted = false # Error if unable to get comments or string literals within max_width, or they are left with trailing whitespaces -fn_params_layout = "Tall" # Control the layout of parameters in function signatures. -fn_single_line = false # Put single-expression functions on a single line -force_explicit_abi = true # Always print the abi for extern items -force_multiline_blocks = false # Force multiline closure bodies and match arms to be wrapped in a block -format_code_in_doc_comments = false # Format the code snippet in doc comments. -format_generated_files = true # Format generated files -format_macro_bodies = true # Format the bodies of declarative macro definitions -format_macro_matchers = true # Format the metavariable matching patterns in macros -format_strings = false # Format string literals where necessary -group_imports = "StdExternalCrate" # Controls the strategy for how imports are grouped together: Preserve, StdExternalCrate or One -hard_tabs = false # Use tab characters for indentation, spaces for alignment -# tab_spaces = 2 # Number of spaces per tab -hex_literal_case = "Upper" # Format hexadecimal integer literals -show_parse_errors = true # -imports_granularity = "Module" # Merge or split imports to the provided granularity - # imports_granularity options: "Preserve": "Do not merge imports" /"Crate": "Use one `use` statement per crate" / "Module": "Use one `use` statement per module" / "Item": " Use one `use` statement per imported item" / "One": Use one `use` statement including all items) -imports_indent = "Block" # Indent of imports -imports_layout = "Mixed" # Item layout inside a import block -indent_style = "Block" # How do we indent expressions or items -make_backup = false # Backup changed files -match_arm_blocks = false # Wrap the body of arms in blocks when it does not fit on the same line with the pattern of arms -match_arm_leading_pipes = "Never" # Determines whether leading pipes are emitted on match arms -match_block_trailing_comma = true # Put a trailing comma after a block based match arm (non-block arms are not affected) -merge_derives = true # Merge multiple ` #[derive(...)]` into a single one -newline_style = "Auto" # Unix or Windows line endings -normalize_doc_attributes = false # Normalize doc attributes as doc comments -overflow_delimited_expr = false # Allow trailing bracket/brace delimited expressions to overflow -print_misformatted_file_names = true # Prints the names of mismatched files that were formatted. Prints the names of files that would be formatted when used with `--check` mode. -remove_nested_parens = true # Remove nested parens -reorder_impl_items = true # Reorder impl items -reorder_imports = true # Reorder import and extern crate statements alphabetically -reorder_modules = true # Reorder module statements alphabetically in group -required_version = "1.8.0" -skip_children = false # Don't reformat out of line modules -space_after_colon = true # Leave a space after the colon -space_before_colon = false # Leave a space before the colon -spaces_around_ranges = false # Put spaces around the .. and ..= range operators -struct_field_align_threshold = 0 # Align struct fields if their diffs fits within threshold -struct_lit_single_line = true # Put small struct literals on a single line -trailing_comma = "Vertical" # How to handle trailing commas for lists -trailing_semicolon = true # Add trailing semicolon after break, continue and return -type_punctuation_density = "Wide" # Determines if '+' or '=' are wrapped in spaces in the punctuation of types -unstable_features = false # Enables unstable features. Only available on nightly channel -use_field_init_shorthand = false # Use field initialization shorthand if possible -use_small_heuristics = "Max" # Whether to use different formatting for items and expressions if they satisfy a heuristic notion of 'small' -use_try_shorthand = true # Replace uses of the try! macro by the ? shorthand -where_single_line = false # Force where-clauses to be on a single line -wrap_comments = false # Break comments to fit on the line +tab_spaces = 2 +max_width = 100 From c2af1c92a78a63410090d9461d148d135cc389c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Falc=C3=A3o?= Date: Sun, 26 Oct 2025 02:43:58 +0000 Subject: [PATCH 8/8] get rid of extra blank lines --- src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f0239c017..20aede292 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -440,7 +440,6 @@ mod macros; pub mod error; pub mod branch; - pub mod combinator; mod internal; pub mod multi; @@ -460,7 +459,6 @@ pub mod number; #[cfg_attr(any(doc, doctest, feature = "docsrs"), doc = include_str!("../doc/nom_recipes.md"))] pub mod recipes {} - #[cfg(all(feature = "std", any(doc, doctest, feature = "docsrs")))] #[cfg_attr(any(doc, doctest, feature = "docsrs"), doc = include_str!("../doc/home.md"))] pub mod guides {