-
Continuing my migration from pub(crate) fn multi_part<'a>() -> impl Parser<'a, &'a str, Part, extra::Err<Rich<'a, char>>> {
recursive(|multipart| {
just(MULTI_PART_BEGIN)
.ignore_then(
choice((
multipart_type(),
#[cfg(feature = "pgp")]
encrypt(),
#[cfg(feature = "pgp")]
sign(),
))
.repeated()
.collect::<HashMap<String, String>>()
.then_ignore(just(GREATER_THAN))
.then_ignore(just(NEW_LINE).or_not()),
)
.then(
choice((
multipart,
attachment(),
single_part(),
text_plain_part().map(Part::TextPlainPart),
))
.repeated()
.collect::<Vec<Part>>()
.then_ignore(just(MULTI_PART_END))
.then_ignore(just(NEW_LINE).or_not()),
)
.map(|(props, parts)| Part::MultiPart(props, parts))
})
} And here the error I get:
|
Beta Was this translation helpful? Give feedback.
Answered by
wackbyte
Sep 15, 2023
Replies: 1 comment 1 reply
-
The error is occuring because |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
soywod
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The error is occuring because
recursive
requires the parser it contains to implementClone
, butimpl Parser
is an opaque type that only implementsParser
and notClone
. Therefore, the solution is likely to add+ Clone
to the return type of all the other parsers you use in this function (multipart_type()
,encrypt()
, etc.).