The `fold` function is missing or the `example/string.rs` needs to be updated
INFCode opened this issue · 2 comments
Prerequisites
Here are a few things you should provide to help me understand the issue:
- Rust version :
rustc 1.70.0 (90c541806 2023-05-31)
- nom version :
1.7.3
- nom compilation features used:
alloc
Issue
It seems that the fold
function (not the fold_many*
functions) is not present in the the document or in the choosing a combinator manual.
However, it is used in the example of parsing a string, which is pointed to by the recipe. Also I can actually find the definition of fold
in the multi
module
I tried to copy that example code into a test project and it failed to compile, with the following error:
error[E0432]: unresolved import `nom::multi::fold`
--> src/parse_string.rs:17:5
|
17 | use nom::multi::fold;
| ^^^^^^^^^^^^^^^^ no `fold` in `multi`
I am relatively new to rust, but I believe there should be some kind of inconsistency here. Either there's missing documentation, or the example needs to be updated.
The master
branch contains examples for the code found on master
(which now includes the fold
combinator). For examples for nom 7.x
, check the 7.x
branch or, better yet, the exact tag of your nom version.
Thank you for pointing this out.
Based on what you said, I think I've figured out what's happening here: the recipe manual is directly linking to the example file through its path on Github (https://github.com/rust-bakery/nom/blob/main/examples/string.rs), which defaults to the one in the master branch. However, as a 7.x manual, the permalink to the example (https://github.com/rust-bakery/nom/blob/869f8972a4383b13cf89574fda28cb7dbfd56517/examples/string.rs) should be used instead.
Could you please update the link so that others will not get confused by this? Thanks a lot!