Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn lift<T>(f: impl Fn(T, T) -> T) -> impl Fn(Option<T>, Option<T>) -> Option<T> {
- move |a, b| match (a, b) {
- (Some(a), Some(b)) => Some(f(a, b)),
- _ => None
- }
- }
- fn main() {
- let add = lift(std::ops::Add::add);
- println!("{:?}", add(Some(1), Some(2)));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement