Merge pull request #3094 from otavio/avoid-unwrap-or
Replace `.unwrap_or` with `.map_or` in few places
This commit is contained in:
commit
8dfdca9390
@ -156,9 +156,7 @@ fn make_opts() -> Options {
|
||||
}
|
||||
|
||||
fn is_nightly() -> bool {
|
||||
option_env!("CFG_RELEASE_CHANNEL")
|
||||
.map(|c| c == "nightly" || c == "dev")
|
||||
.unwrap_or(false)
|
||||
option_env!("CFG_RELEASE_CHANNEL").map_or(false, |c| c == "nightly" || c == "dev")
|
||||
}
|
||||
|
||||
// Returned i32 is an exit code
|
||||
|
@ -345,9 +345,9 @@ pub fn rewrite_last_closure(
|
||||
|
||||
// When overflowing the closure which consists of a single control flow expression,
|
||||
// force to use block if its condition uses multi line.
|
||||
let is_multi_lined_cond = rewrite_cond(context, body, body_shape)
|
||||
.map(|cond| cond.contains('\n') || cond.len() > body_shape.width)
|
||||
.unwrap_or(false);
|
||||
let is_multi_lined_cond = rewrite_cond(context, body, body_shape).map_or(false, |cond| {
|
||||
cond.contains('\n') || cond.len() > body_shape.width
|
||||
});
|
||||
if is_multi_lined_cond {
|
||||
return rewrite_closure_with_block(body, &prefix, context, body_shape);
|
||||
}
|
||||
|
@ -72,9 +72,7 @@ impl ConfigType for IgnoreList {
|
||||
/// nightly compiler when installed from crates.io, default to nightly mode.
|
||||
macro_rules! is_nightly_channel {
|
||||
() => {
|
||||
option_env!("CFG_RELEASE_CHANNEL")
|
||||
.map(|c| c == "nightly" || c == "dev")
|
||||
.unwrap_or(true)
|
||||
option_env!("CFG_RELEASE_CHANNEL").map_or(true, |c| c == "nightly" || c == "dev")
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -273,11 +273,9 @@ pub fn format_expr(
|
||||
|
||||
format!(
|
||||
"{}{}{}",
|
||||
lhs.map(|lhs| space_if(needs_space_before_range(context, lhs)))
|
||||
.unwrap_or(""),
|
||||
lhs.map_or("", |lhs| space_if(needs_space_before_range(context, lhs))),
|
||||
delim,
|
||||
rhs.map(|rhs| space_if(needs_space_after_range(rhs)))
|
||||
.unwrap_or(""),
|
||||
rhs.map_or("", |rhs| space_if(needs_space_after_range(rhs))),
|
||||
)
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user