diff options
| author | Sébastien d'Herbais de Thun <sebastien.d.herbais@gmail.com> | 2023-04-04 19:21:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-04 19:21:25 +0200 |
| commit | f347ed4314e32383dc09ff234180e8ea6fef7b8b (patch) | |
| tree | dba4296812a131e52da4eb0079fd0d240860d832 /src/geom | |
| parent | 5b0297464efc131beb7be84fa7a02b9a8670b5dd (diff) | |
Improved figure numbering, labelling and referencing (#491)
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 |
