pub fn ready<In: Input, T: Clone, Reason>(
value: T,
) -> impl Parser<In, T, Reason>Expand description
Returns a parser that always returns the provided value.
Beware that the value is always cloned.
Examples found in repository?
examples/xml.rs (line 84)
75fn parse_tag<In: Input>(input: In) -> ParsingResult<In, Fragment<In>, Error> {
76 parse_whitespace::<In, Error>
77 .then(parse('<'))
78 .then(parse_whitespace)
79 .then(parse('/').ok())
80 .skip(parse_whitespace)
81 .and(parse_ident)
82 .skip(parse_whitespace)
83 .map(match_out! {
84 (true, name) => ready(Fragment::ClosingTag { name }),
85 (false, name) => parse_attr
86 .collect()
87 .and(parse('/').ok())
88 .skip(parse_whitespace)
89 .map_out(|(attrs, self_closing)| Fragment::Tag { self_closing, name: name.clone(), attrs })
90 })
91 .skip(parse_whitespace)
92 .skip(parse('>').or_reason(Error::TagUnclosed))
93 .parse(input)
94}