I have the following code that ignores NotFound errors.
/// Map not found error to ok
fn allow_not_found(input: io::Result<()>) -> io::Result<()> {
match input {
Ok(()) => Ok(()),
Err(e) if e.kind() == io::ErrorKind::NotFound => Ok(()),
Err(e) => Err(e),
}
}
If I try to compile the second line of the match without the ref e (as shown), I get a build error (cannot bind by-move into a pattern guard).
With the changes around not requiring ref, maybe instead of failing to compile the above example could just default to ref in the guard, even though the match itself is a move match?
Would there be and problems with this approach I haven’t thought of?
Only things that might be a problem off the top of my head: