Add more range API's.

This commit is contained in:
Stephen Chung
2021-12-15 22:12:51 +08:00
parent 59a9ff0b0f
commit abbfa3777d
5 changed files with 42 additions and 28 deletions

View File

@@ -213,6 +213,16 @@ impl Position {
#[cfg(feature = "no_position")]
return true;
}
/// Returns an fallback [`Position`] if it is [`NONE`][Position::NONE]?
#[inline]
#[must_use]
pub const fn or_else(self, pos: Self) -> Self {
if self.is_none() {
pos
} else {
self
}
}
/// Print this [`Position`] for debug purposes.
#[inline]
pub(crate) fn debug_print(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {