Fix whitespace gobbling
Right now each field trims its own input when called with trimmed_step
. But this interacts badly with regexes and before/after.
- before+regex+after should parse even if the regex starts or ends with with whitespace
- before+regex+after should parse even if the regex has no whitespace
- the derive macro should include gobbling based on its own attributes (e.g.
#[inpt(leave_whitespace)]
or#[inpt(whitespace="\t")]
) - the derive macro should do custom gobbling on types that want it (e.g. commas and number types)
Probably the altered regexes should include \s*
prefixes/postfixes depending on what before/after fields exist. Trimming at the start and end of input should only happen once. And otherwise the gobbling should be done between fields only with something like
field_0, rest = A::step(rest, false);
rest = B::gobbler().or(A::gobbler()).or(INTERNAL_GOBBLER).map(|g| g.trim(rest)).unwrap_or(rest);
field_1, rest = B::step(rest, end);
Should custom gobblers using regex class syntax be allowed?
Edited by Sam Sartor