Open
Description
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:
#[derive(Debug, ProvidesStaticType, NoSerialize, Allocative, Clone, Default, Display)]
#[display("myvalue {:?}", providers)]
struct MyValueGen {
mapping: HashMap<String, AnotherStruct>,
}
impl MyValueGen {
fn new() -> Self {
MyValueGen {
mapping: HashMap::new(),
}
}
}
starlark_complex_value!(MyValue);
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!
Metadata
Metadata
Assignees
Labels
No labels