diff options
Diffstat (limited to 'src/geom')
| -rw-r--r-- | src/geom/smart.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/geom/smart.rs b/src/geom/smart.rs index c977d651..d9f8fd16 100644 --- a/src/geom/smart.rs +++ b/src/geom/smart.rs @@ -20,6 +20,15 @@ impl<T> Smart<T> { matches!(self, Self::Custom(_)) } + /// Returns a reference the contained custom value. + /// If the value is [`Smart::Auto`], `None` is returned. + pub fn as_custom(self) -> Option<T> { + match self { + Self::Auto => None, + Self::Custom(x) => Some(x), + } + } + /// Map the contained custom value with `f`. pub fn map<F, U>(self, f: F) -> Smart<U> where |
