Commit 855cdd4
committed
Add
A small wrapper for `impl CtOption<T> for Option<T>` which is friendlier
for type inference purposes.
Using `Option::from(ct_option)` often doesn't work because the compiler
is unable to infer `T` for `Option<T>`, so you have to manually annotate
`Option::<T>::from`.
In practice this often winds up looking like:
Option::<T>::from(T::constructor(x))`
which feels quite redundant.
Using an inherent method instead fixes type inference so the above can
be:
T::constructor(x).into_option()CtOption::into_option
1 parent 6b6a81a commit 855cdd4
1 file changed
+16
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
801 | 801 | | |
802 | 802 | | |
803 | 803 | | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
804 | 820 | | |
805 | 821 | | |
806 | 822 | | |
| |||
0 commit comments