File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -794,6 +794,22 @@ impl<T> CtOption<T> {
794
794
795
795
Self :: conditional_select ( & self , & f, is_none)
796
796
}
797
+
798
+ /// Convert the `CtOption<T>` wrapper into an `Option<T>`, depending on whether
799
+ /// the underlying `is_some` `Choice` was a `0` or a `1` once unwrapped.
800
+ ///
801
+ /// # Note
802
+ ///
803
+ /// This function exists to avoid ending up with ugly, verbose and/or bad handled
804
+ /// conversions from the `CtOption<T>` wraps to an `Option<T>` or `Result<T, E>`.
805
+ /// This implementation doesn't intend to be constant-time nor try to protect the
806
+ /// leakage of the `T` since the `Option<T>` will do it anyways.
807
+ ///
808
+ /// It's equivalent to the corresponding `From` impl, however this version is
809
+ /// friendlier for type inference.
810
+ pub fn into_option ( self ) -> Option < T > {
811
+ self . into ( )
812
+ }
797
813
}
798
814
799
815
impl < T : ConditionallySelectable > ConditionallySelectable for CtOption < T > {
You can’t perform that action at this time.
0 commit comments