Skip to content
Discussion options

You must be logged in to vote

Is there a way to drop a PyRef and get a ref to the PyCell at the same time?

I don't think we have such a method. The best you can do is get a Py<T> back from the PyRef<T> via a From impl.

I tried to keep my question as brief as possible but I can add more detail about my use-case if it helps.

I am not sure that the short-lived borrows can be avoided, but I think discussing the whole problem could only help to figure out if there are any alternative solutions.

One slightly different approach might be to avoid PyCell completely using a frozen #[pyclass] and use a more fine-grained approach to interior mutability, i.e. all your methods take &self and your individual fields implement int…

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@cspotcode
Comment options

@adamreichold
Comment options

@cspotcode
Comment options

@adamreichold
Comment options

@cspotcode
Comment options

Answer selected by cspotcode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants