Use new Match::or to simplify return

This commit is contained in:
Jacob Wahlgren
2016-11-06 01:01:14 +01:00
parent 1aeae3e22d
commit a05671c8d7
2 changed files with 11 additions and 13 deletions

View File

@@ -297,4 +297,13 @@ impl<T> Match<T> {
Match::Whitelist(t) => Match::Whitelist(f(t)),
}
}
/// Return the match if it is not none. Otherwise, return other.
pub fn or(self, other: Self) -> Self {
if self.is_none() {
other
} else {
self
}
}
}