Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow empty sep for separated_list but not sep and f empty #1444

Closed
wants to merge 1 commit into from
Closed

Allow empty sep for separated_list but not sep and f empty #1444

wants to merge 1 commit into from

Conversation

Stargateur
Copy link
Contributor

@Stargateur Stargateur commented Oct 25, 2021

Fix #1288

This make more sense to consider both should be empty to be in infinite loop, and follow expected behavior of:

let (input, output) = separated_list0(opt(char(',')), parser)(input);

equivalent to manually do:

let (input, output) = parser(input)?;
let acc = vec![output];
let (input, output) = fold_many0(
  preceded(opt(char(',')), parser),
  || acc,
  |mut acc, output| { acc.push(output); acc },
)(input)

where fold_many0 fail only if the both seq and item parser are empty.

@coveralls
Copy link

coveralls commented Oct 25, 2021

Coverage Status

Coverage decreased (-2.8%) to 81.163% when pulling eeecd7d on Stargateur:fix_list_sep into 4a2f9af on Geal:master.

@Stargateur Stargateur closed this Oct 31, 2021
@dalcde
Copy link

dalcde commented Mar 29, 2022

Why was this PR closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

separated_list1 fails if separator is empty
3 participants