You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm struggling to find an implementation of a complex_value type that allows for mutation of its attributes. I'm confused on a number of aspects and I was hoping to clear them up with some help. Suppose I want a Value like this:
How do I implement a method that can be called from starlark that can update the HashMap with a new pair of items. Any attempt I try tells me that I can't get a mutable reference to that attribute.
I've found #126, but the complicated example confuses me here. Do I create another struct that is Mutable w/ a RefCell and use that for all operations? That seems like a lot of boilerplate....
If I could get a hint, then I think it would really help me get started. Thanks!
The text was updated successfully, but these errors were encountered:
You will need to use a RefCell for all operations.
Assuming you also want to use this for frozen values (e.g. non-mutable), you'll have to have both a frozen version and a non-frozen version.
And yeah, it is a fair bit of boilerplate. Unfortunately we couldn't figure out a way to abstract over mutability in Rust, so this was the best we could figure out.
Hi, I'm struggling to find an implementation of a complex_value type that allows for mutation of its attributes. I'm confused on a number of aspects and I was hoping to clear them up with some help. Suppose I want a Value like this:
How do I implement a method that can be called from starlark that can update the
HashMap
with a new pair of items. Any attempt I try tells me that I can't get a mutable reference to that attribute.I've found #126, but the complicated example confuses me here. Do I create another struct that is Mutable w/ a
RefCell
and use that for all operations? That seems like a lot of boilerplate....If I could get a hint, then I think it would really help me get started. Thanks!
The text was updated successfully, but these errors were encountered: