Oh god! I feel this ... I've bitten into my inner cheek real bad in the past! Hope you heal well!
I don't know where you got up to last stream but I'm presuming you've gotten a fair way through the smart pointers chapter (perhaps finished it).
Any one have thoughts on them or general experience with the concept? I don't and am curious what everyday use cases they offer (as I'm unclear)
As far as Box
is concerned, I get the use case for large data structures, where moving a pointer around is cheaper but because it also owns its data you don't have to worry about lifetimes.
I've seen (and posted somewhere here before) about how a struct
should never have a reference as a field but should have a box
instead ... not sure I appreciate what that scenario looks like.
Rc
seems genuinely useful as a way of just opting out of lifetimes and ownership when the data doesn't need to be mutable.
And then RefCell
, especially in combination with Rc
, seems ideal for constructing interesting data structures that seems much more natural for package development rather than in application, but feels like a nice technique for when the time comes. Anyone aware of some good patterns of general use with RefCell
and Rc
?
I'm currently reading through the concurrency chapter and it seems that the smart pointers of most practical use might be the concurrent equivalents: Arc
(concurrent equivalent of Rc
) and Mutex
(concurrent equivalent of RefCell
).
Beyond all of that ... this stream is pretty close to finishing the book and moving on to other more practical things ... any one have any thoughts on what to do that could work well at a collective level?