Skip to content

not API changed on v1.0.0-alpha.4 #523

Answered by Zij-IT
soywod asked this question in Q&A
Discussion options

You must be logged in to vote

In this case to get the desired behavior you use something like (map_)slice:

pub(crate) fn text_plain_part<'a>() -> impl Parser<'a, &'a str, String, extra::Err<Rich<'a, char>>> {
    any()
        .and_is(
            choice((
                just(SINGLE_PART_BEGIN),
                just(SINGLE_PART_END),
                just(MULTI_PART_BEGIN),
                just(MULTI_PART_END),
            ))
            .not()
        )
        .repeated()
        .at_least(1)
        .map_slice(ToString::to_string)
}

The any().and_is(/* snip */) is required because an empty parse is valid for something.not() and therefore will infinite loop without progress when used in combination with repeated. By…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@soywod
Comment options

@zesterer
Comment options

@zesterer
Comment options

@soywod
Comment options

Answer selected by soywod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants