Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(box_syntax)]
- #![feature(trait_alias)]
- #![feature(unboxed_closures)]
- fn c<T: FnMutClone<()>>(x: T) {}
- trait FnClone<Args>: Fn<Args> {
- fn clone_fn(&self) -> Box<dyn FnClone<Args, Output = Self::Output>>;
- }
- impl<Args, T: Fn<Args> + Clone + 'static> FnClone<Args> for T {
- fn clone_fn(&self) -> Box<dyn FnClone<Args, Output = Self::Output>> { Box::new(self.clone()) }
- }
- trait FnMutClone<Args>: FnMut<Args> {
- fn clone_fn(&self) -> Box<dyn FnMutClone<Args, Output = Self::Output>>;
- }
- impl<Args, T: FnMut<Args> + Clone + 'static> FnMutClone<Args> for T {
- fn clone_fn(&self) -> Box<dyn FnMutClone<Args, Output = Self::Output>> { Box::new(self.clone()) }
- }
- fn a() -> Box<dyn FnMutClone() -> ()> {
- let a = 1;
- box move || { a += 1; }
- }
- fn main() {
- c(a())
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement