does anyone know if there's a way in rust to map i...
# development
h
does anyone know if there's a way in rust to map into a
Mutex
?
a
what do you mean by "map into" here?
h
i.e. if I have
Arc<Mutex<T>>
and
T
has some function
&self -> foo
on it, can I easily get a
Arc<Mutex<foo>>
?
a
ooh, great question
my first thought is that you'd at least need to make a new
Arc
, since you can't stick it in the same spot as the old one
and then my next thought was that you'd probably have to make a new
Mutex<>
too, since mutexes are paired with types in rust, so i was going to look through the constructors for Mutex
would you want to Drop the old
Arc<Mutex<T>>
at the same time?
h
nah
basically I'm trying to make the type contained within an
Arc<Mutex<_>>
in
WorkUnitStore
more complicated
without changing the contract provided by
get_workunits
and I'm not sure what hte cleanest way to do this is
a
i was thinking that
Arc::new(Mutex::new(self.get_foo())
would make sense, but not sure if you can construct a mutex like that
lmk if that doesn't work or doesn't sound right
h
so, I would already have to unlock the first mutex to wrap part of the contained value in a new mutex
I'm not sure this works