.map_or()
with identity closure RS-W1201Calling map_or
with the identity closure is equivalent to using unwrap_or
which is both easier to read and generally more performant.
Consider replacing map_or
with unwrap_or
.
let foo = vec![1, 2, 3];
let bar = foo.get(1).map_or(0, |x| x);
let foo = vec![1, 2, 3];
let bar = foo.get(1).unwrap_or(0);