Closed jeanm closed 7 years ago
nom has a very useful map_res combinator:
map_res
applies a function returning a Result to the output of IResult, returns Done(input, o) if the result is Ok(o), or Error(0)
IResult
Done(input, o)
Ok(o)
Error(0)
Something like that would come in handy to get rid of all the unwrap()s in places like:
unwrap()
.map(|bytes|String::from_utf8(bytes).unwrap())
(there are a few cases of this in your JSON example code)
Added p.convert(f), this makes the parser code neater.
p.convert(f)
nom has a very useful
map_res
combinator:Something like that would come in handy to get rid of all the
unwrap()
s in places like:(there are a few cases of this in your JSON example code)