Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[derive(Debug)]
- struct MyStruct;
- type MyFunction = FnOnce(MyStruct) -> Result<MyStruct, ()> + Send;
- fn main() {
- let functions: Vec<Box<MyFunction>> = vec![Box::new(|s| -> Result<MyStruct, ()> { Ok(s) })];
- let s = functions
- .into_iter()
- .fold(Ok(MyStruct), |result_s, boxed_f| {
- result_s.and_then(|s| boxed_f(s))
- // Error here: ^^^^^^^ cannot move a value of type std::ops::FnOnce(..)
- // But shouldn't it be moving the box which is `Sized`, not the function inside the box?
- });
- print!("{:?}", s);
- }
Add Comment
Please, Sign In to add comment