Rust book Ch20.2, why bother with `job` dereferencing?

At the end of Ch20.2 of Rust Book a problem of job dereferencing is discussed, and since Rust complains that it "cannot move a value of type dyn std::ops::FnOnce() + std::marker::Send: the size of dyn std::ops::FnOnce() + std::marker::Send cannot be statically determined", the book suggest to implement trait FnBox with call_box() for FnOnce to "take ownership of self and move the value out of the Box". As it said, "This trick is very sneaky and complicated", but the first thing I thought was why bother with dereferencing at all? I just tried to use job() instead of (*job)() and that worked fine without any error.
So I totally didn't catch all the magic with all that "taking ownership of Self", could you please explain this to me?

The book is out of date, FnBox is now obsolete.

2 Likes

Thanks! Could you please refer me the changes that made FnBox obsolete? (*job)() still doesn't work :slight_smile:

https://github.com/rust-lang/rust/pull/61113

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.