use dangerous::{Error, Invalid, Reader};
fn parse<'i, E: Error<'i>>(r: &mut Reader<'i, E>) -> Result<(), E> {
let consumed = r.try_take_consumed(|r| {
// We take a exact length of input
r.consume(b"blah")
})?;
// This produces a `RetryRequirement` when it should be fatal?
consumed.read_all(|r| r.consume(b"blah1"))
}
let input = dangerous::input(b"blah");
let result: Result<_, Invalid> = input.read_all(parse);
assert_eq!(result, Err(Invalid::fatal()));
This can be fixed with: consumed.bound(), but this is a footgun I don't like.
What is written is a bug, but with the trust in RetryRequirement would cause a infinite loop of asking for more input rather than throwing an error. This would make finding the bug impossible in logs unless a max retry was used.
Currently failing:
This can be fixed with:
consumed.bound()
, but this is a footgun I don't like. What is written is a bug, but with the trust inRetryRequirement
would cause a infinite loop of asking for more input rather than throwing an error. This would make finding the bug impossible in logs unless a max retry was used.