-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrap environments
in RefCell
#441
Conversation
Does it matter if we carry around a mutable reference to manager? |
If we do want to remove pub fn get_environment<S: Into<String>>(&self, label: S) -> Option<&Environment> {
self.environments.borrow().get(label)
} |
I figure there may be cases where you want to carry many references to the manager at one time (e.g. you want to create several environments with different configurations?). It wouldn't be possible to satisfy rust borrow rules in this scenario. |
I think this is a good change and am for merging this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
I don't think I follow. With the current set up, I can create multiple environments with different configs and I don't run into any borrow rules. I can just let mut manager = Manager::new();
manager.add_environment("label",..);
manager.add_environment("label_2",..);
// ~ etc. It would only matter if we have a function like so: fn do_something(mut manager: Manager) .. |
Maybe we close this for now? Thoughts @kinrezC and @Autoparallel? |
That's my preference. I think we should revisit something like this if we run into an issue down the road in making simulations. |
Currently in order to add environments to the manager one must carry a mutable reference to the manager. Using
RefCell
allows you to track an immutable reference to the manager while allowing for interior mutability on the environments.