Last active
December 7, 2021 13:05
-
-
Save abiriadev/8662f5e2eab184ea1858ec449fc906de to your computer and use it in GitHub Desktop.
lol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() -> Result<( | |
) | |
, Box< | |
dyn std | |
::error | |
::Error | |
> | |
> { | |
let number1: | |
i32 = 1; | |
let number2: | |
u8 = 2; | |
if let Option | |
::Some( | |
res | |
) = add_two( | |
number1, | |
number2, | |
) as Option<i64> { | |
println!("{}", res); | |
} | |
Ok(()) | |
} | |
fn add_two<T: std | |
::convert | |
::Into<V> | |
, V: std | |
::ops | |
::Add< | |
Output = V | |
> | |
, U | |
>( | |
a: T, | |
b: U, | |
) -> Option<V> where | |
U: std | |
::convert | |
::Into<V> | |
, | |
{ | |
enum E< | |
T, | |
V, | |
> { | |
A(T), | |
B(V), | |
} | |
[ E::A(a) | |
, E::B(b) | |
] | |
.map( | |
| val | | |
match val { | |
E::A(a) => a.into(), | |
E::B(b) => b.into(), | |
} | |
) | |
.into_iter() | |
.reduce( | |
| s, a | | |
s + a | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment