Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait FnBox {
- fn call_box(self: Box<Self>);
- }
- impl<F: FnOnce() + ?Sized> FnBox for F {
- fn call_box(self: Box<F>) {
- (*self)()
- }
- }
- fn main() {
- let x = "test".to_string();
- let f = Box::new(move || { x; });
- f.call_box();
- }
Add Comment
Please, Sign In to add comment