Is that a case for interior mutability needs?

Hi again,

I'm trying to combine two crates and the API seems quite incompatible to me:

reg_fct only gives me &self but I need to call operation which needs &mut self. I though that might be the place to use a Cell but I can't make it compile with a Cell neither.

What am I missing here?

Cell doesn't let you get a reference to it's internals, so you will need to take Connection out of the Cell temporarily, and then call operation, then you can put it back in the Cell (but this may be difficult to do). Another way to do this is using RefCell, which may be easier to use because it does give you direct access to it's wrapped value.

Cell: Rust Playground
RefCell: Rust Playground

1 Like

Thanks a lot! I went the RefCell route :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.