Replies: 3 comments 3 replies
-
I have satisfied the compiler using
but
|
Beta Was this translation helpful? Give feedback.
-
You could do |
Beta Was this translation helpful? Give feedback.
-
In general, if you are porting from |
Beta Was this translation helpful? Give feedback.
-
I have been using winnow for a few AoC quizzes and have now been trying to port some more serious binary file format parser from nom to winnow. Mostly, I love how it turns out, but this file format has a few peculiarities, so I need to deviate from the stuff tought in the tutorial and find myself running into errors around the error type:
PResult<T>
, but how do I now report errors from custom logic? For instance, I have successfully parsed a configuration table that's part of the file header, and I later need to to look up various (string) keys in that table. How should I report that such a key is missing? Given a std rustResult
with my custom error, I have tried.map_err(|_| ErrMode::Cut(InputError::new(tag_list_input, ErrorKind::Tag)))?
for instance, but that's both ugly and not working yet (InputError vs. ContextError, I guess).input.split_at()
to get two inputs for further parsing. Trying to parse the above-mentioned configuration table from the stripped-off section, I have been tryingmy_configuration_table_parser.parse(section)
(instead of the.parse_next()
s usually used), but that also yields the wrong error type (in the sense that I cannot just pass it on using?
). Of course, I could use.parse_next()
on a mut ref, but then I would have to check myself that it has parsed the full section.Maybe I am just revealing that I have not yet understood all best practices w.r.t. Rust's error handling (and all the available generic third-party crates).
Beta Was this translation helpful? Give feedback.
All reactions