Any takers on helping a Rust newbie on an ownershi...
# development
b
Any takers on helping a Rust newbie on an ownership issue? 🧵
I want to have the
Instance
also contain either the
MultiProgress
or a reference to it to be used in
render()
.
But the object is moved inside the
multi_progress_task
It's been a while since I wore my C++ hat, and Rust seems to be a bit more stringent with references/lifetimes so I'm floundering
I'm pretty sure I need to sparn the task after I move the MultiProgress object, or else how would the reference be valid. Seems like a two-phase initialization problem 😭
f
you’d typically have a “handle” type that could be cheap to clone and have both places hold on their own reference
Arc
is one such smart pointer
and if the accesses need to occur from multiple threads, you might see
Arc<Mutex<T>>
as a pattern
b
This helped, btw! 🙌