Inverse of Option<T>?

I have a piece of code that looks like:

if let Some(x) = side_effect_1() {
  return Some(x);
}

if let Some(x) = side_effect2() {
  return Some(x);
}

if let Some(x) = side_effect_3() {
  return Some(x);
}

return None

This is almost like the inverse of '?'. Is there a better way to refactor this?

One way is the following:

return side_effect_1()
    .or_else(side_effect_2)
    .or_else(side_effect_3);
4 Likes