What it does
Replace Some(f(...?)) or Ok(f(...)?) as a return value with (...).map(f). Potentially an addition to manual_map.
Advantage
Clearer, has less nesting, and can be more concise. Helps discoverability of Option::map etc.
Drawbacks
Can be less concise.
Example
fn maybe_len(maybe_string: Option<&str>) -> Option<usize> {
Some(maybe_string?.len())
}
Could be written as:
fn maybe_len(maybe_string: Option<&str>) -> Option<usize> {
maybe_some_string.map(|s| s.len())
}
What it does
Replace
Some(f(...?))orOk(f(...)?)as a return value with(...).map(f). Potentially an addition tomanual_map.Advantage
Clearer, has less nesting, and can be more concise. Helps discoverability of
Option::mapetc.Drawbacks
Can be less concise.
Example
Could be written as: