chumsky icon indicating copy to clipboard operation
chumsky copied to clipboard

Update `separated_by` docs to be more in-line with `repeated` docs

Open sineptic opened this issue 8 months ago • 4 comments

I want use .repeat(), but it changes Parser output to ().

I found that it happens on line 1518 in file src/combinator.rs and output changed to () in commit b38db3e1e5ef6e94b690b08fdb77064d98ff3823.

sineptic avatar Apr 25 '25 16:04 sineptic

Correct (: Depending on what your goal with repeated is, you can collect it into a vector of elements using IterParser::collect

Zij-IT avatar Apr 25 '25 19:04 Zij-IT

Ok, I see. Thank you. I have issue with calling .repeated().separated_by(). It would be nice if documentation for separated_by would have this caution and/or if Container trait would have #[diagnostic::on_unimplemented] with some note, because now it says, that Container<()> not implemented for Vec<String>.

sineptic avatar Apr 26 '25 08:04 sineptic

How would you implement https://github.com/zesterer/chumsky/issues/184 in 0.10? I'm running into the same issue with

    text::digits(10)
        .repeated()
        .at_least(1)
        .separated_by(just('_'))
        .collect::<String>()

Keats avatar May 14 '25 14:05 Keats

It would be nice if documentation for separated_by would have this caution

The docs for separated_by should probably be updated to align with repeated.

I'm running into the same issue with

text::digits(10) implicitly gives you a repeating parser, there is no need to call .repeated() on it a second time.

zesterer avatar May 19 '25 15:05 zesterer