I'm writing these iterators just fine without lifetimes, but now all of a sudden:
fn check_year_record<'a>(
input: &'a str,
field: &str,
lower_bound: u16,
upper_bound: u16,
) -> IResult<&'a str, u16> {
let field = field.to_string() + ":";
let (_, number) = terminated(
preceded(
tag(field.as_str()),
map_res(digit1, |s: &str| s.parse::<u16>()),
),
multispace0,
)(input)?;
if number >= lower_bound && number <= upper_bound {
return Ok(("", number));
} else {
return Err(nom::Err::Error(nom::error::Error::new(
"",
nom::error::ErrorKind::Digit,
)));
}
}
This does not compile anymore without them. I introduced the field
that is concatenated, so is that allocation forcing me to add these?
I don't understand how adding this suddenly breaks the entire thing. It worked fine before and the allocation of field + ":"
has no consequence for any of the other fields.