Description
If you'd like to fix this bug, here's how.
Currently iterator::inspect contains the following documentation:
It's much more common for inspect() to be used as a debugging tool than to exist in your final code, but never say never.
Though I like the never say never wording, I think it might be helpful to document a use case where it's not used for debugging. I use inspect
in daemon applications for that slurp in stdin lines and discard and log the lines that can't be parsed. Like so:
lines
.iter()
.map(|line| parse_line(line))
.inspect(|line| {
// If we can't parse a line, yeah that sucks but it's bound to happen so discard
// the line after it's logged for the attentive sysadmin
if let Err(ref e) = *line {
error!("Parsing error: {}", e);
}
})
.flat_map(|x| x)
// etc
Maybe the documentation of inspect can be updated to something like:
It's more common for inspect() to be used as a debugging tool than to exist in your final code, but applications may find it useful in certain situations as well. Say an application is reading stdin lines, it may be it helpful to log lines with errors before discarding them.
What do you think? Suggestions certainly wanted 😄