Skip to content

Use unwrap_or_default instead of unwrap_or_else(Default::default)

Robin Leander Schröder requested to merge rls/arti:fix-clippy-warning into main

Fixes the following clippy warning:

warning: use of `.unwrap_or_else(..)` to construct default value
   --> tor-netdoc/src/doc/netstatus/rs.rs:304:22
    |
304 |           let weight = sec
    |  ______________________^
305 | |             .get(RS_W)
306 | |             .map(RelayWeight::from_item)
307 | |             .transpose()?
308 | |             .unwrap_or_else(Default::default);
    | |_____________________________________________^
    |
    = note: `#[warn(clippy::unwrap_or_else_default)]` on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_else_default
help: try
    |
304 ~         let weight = sec
305 +             .get(RS_W)
306 +             .map(RelayWeight::from_item)
307 ~             .transpose()?.unwrap_or_default();
    |

Merge request reports

Loading