Last active
August 31, 2019 02:54
-
-
Save mmmpa/83b533e1a222b606381e8e3eee0b06a5 to your computer and use it in GitHub Desktop.
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 prepare<A: Clone + 'static, B: Clone, C, AB: Fn(A, B) -> C + 'static>(op: AB) -> Box<dyn Fn(A) -> Box<dyn Fn(B) -> C>> { | |
let op_rc = Rc::new(op); | |
Box::new( | |
move |a: A| { | |
let a_rc = Rc::new(a.clone()); | |
let op_rc = op_rc.clone(); | |
Box::new(move |b: B| { | |
let a = a_rc.as_ref(); | |
let op = op_rc.as_ref(); | |
op(a.clone(), b.clone()) | |
}) | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment