Function list

Source
pub fn list<I, O, E, L>(
    reasonable_count: usize,
    element: L,
    input: I,
) -> IResult<I, Vec<Option<O>>, E>
where L: Parser<I, Output = O, Error = E>, E: ParseError<I>, I: Input + Copy, <I as Input>::Item: AsChar,
Expand description
#rule
#element => [ element ] *( OWS "," OWS [ element ] )

RFC 9110 specifies that:

A recipient MUST parse and ignore a reasonable number of empty list elements: enough to handle common mistakes by senders that merge values, but not so much that they could be used as a denial-of- service mechanism.

However, the RFC does not specify what a “reasonable” value for this is, so we allow the user to configure such a limit.

In this implementation, empty list elements are represented as None in the returned Vec, and non-empty list elements are represented as Some<E>