Sharing immutable reference to mutable struct in a single thread

Hi! I'm completely new to rust, and I'm having trouble with wrapper types and ownership (Boxes, Cells, Refcells, and the like). How would you implement something like the 'foo' below, if you needed 'data' to be mutable, did not need to run anything in more than one thread, and wanted to stay within safe rust?

fn foo(value: T, data: SomeWrapper<SomeStruct>) {

I apologize if this is vague or dumb, I don't have much experience with systems programming.

With data: &RefCell<SomeStruct>, you can use data.borrow_mut().vector_field.push(...).

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.