pub fn optional<'a, Input>(
input: Input,
) -> IResult<Input, Optional<Input>, Error<Input>>where
Input: Clone + Display + Offset + InputLength + InputTake + InputTakeAtPosition<Item = char> + Slice<RangeFrom<usize>> + InputIter + for<'s> Compare<&'s str> + 'a,
<Input as InputIter>::Item: AsChar + Copy,
Error<Input>: ParseError<Input>,
for<'s> &'s str: FindToken<<Input as InputIter>::Item>,
Expand description
Parses an optional
as defined in the grammar spec.
§Grammar
optional = '(' text-in-optional+ ')'
text-in-optional = (- optional-to-escape) | ('\', optional-to-escape)
optional-to-escape = '(' | ')' | '{' | '/' | '\'
§Example
(name)
(with spaces)
(escaped \/\{\()
(no need to escape })
(🦀)
§Errors
§Recoverable Error
- If
input
doesn’t start with(
.