diff --git a/src/lib.rs b/src/lib.rs index 530ae36..b7584c0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -794,6 +794,22 @@ impl CtOption { Self::conditional_select(&self, &f, is_none) } + + /// Convert the `CtOption` wrapper into an `Option`, depending on whether + /// the underlying `is_some` `Choice` was a `0` or a `1` once unwrapped. + /// + /// # Note + /// + /// This function exists to avoid ending up with ugly, verbose and/or bad handled + /// conversions from the `CtOption` wraps to an `Option` or `Result`. + /// This implementation doesn't intend to be constant-time nor try to protect the + /// leakage of the `T` since the `Option` will do it anyways. + /// + /// It's equivalent to the corresponding `From` impl, however this version is + /// friendlier for type inference. + pub fn into_option(self) -> Option { + self.into() + } } impl ConditionallySelectable for CtOption {