Guest User

Untitled

a guest
Jun 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #[derive(Debug)]
  2. struct MyStruct;
  3.  
  4. type MyFunction = FnOnce(MyStruct) -> Result<MyStruct, ()> + Send;
  5.  
  6. fn main() {
  7. let functions: Vec<Box<MyFunction>> = vec![Box::new(|s| -> Result<MyStruct, ()> { Ok(s) })];
  8. let s = functions
  9. .into_iter()
  10. .fold(Ok(MyStruct), |result_s, boxed_f| {
  11. result_s.and_then(|s| boxed_f(s))
  12. // Error here: ^^^^^^^ cannot move a value of type std::ops::FnOnce(..)
  13. // But shouldn't it be moving the box which is `Sized`, not the function inside the box?
  14. });
  15.  
  16. print!("{:?}", s);
  17. }
Add Comment
Please, Sign In to add comment