Why does map_res closure not simply return Option
gdennie opened this issue · 3 comments
In nom
(currently v7.1.3 with rust nightly)...
The map_res
function requires a closure that returns core::result::Result<T,E>
. However, map_res
does actually use the Err
discriminant's value. However, requiring a Result<T,E>
result type complicates type conformance as well as the code. As such, I am curious as to why Option<T>
was not chosen for the closure result type.
map_res
requires its error value to implement nom::err::FromExternalError
which requires the result error value. However, current error type implementations by nom
namely ()
, (I, ErrorKind)
, and VerboseError
do not even hold this value.
It is meant for use with a custom error type that can hold the external error yes. If you don't use it, why not try map_opt?
Did not know about map_opt
, as such. Recall seeing the name once or twice in the docs. Will now be using it.
Thanks.