https://pantsbuild.org/ logo
#development
Title
# development
b

bitter-ability-32190

01/21/2022, 5:51 PM
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

fast-nail-55400

01/21/2022, 6:07 PM
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

bitter-ability-32190

01/21/2022, 8:19 PM
This helped, btw! 🙌