-
Notifications
You must be signed in to change notification settings - Fork 22
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
IntrusiveQCellOwner? #30
Comments
This isn't going to work. As you say, the owner is the cell itself. However to borrow mutably from the cell you need a The whole point of these cell types is to temporarily "transfer" mutability from one thing to something else that has only immutable access. In this case (plain |
This is sound. It's just kinda (read: very) weird. The mutability would be held by the "original |
I'm still having trouble figuring out what you're trying to do. So I think what you're saying is that the "original Arc" is the owner, and so accessing through the "original Arc" would allow modification of the cell contents. You say you're not going to allow cloning, but in your example code you have However if the only Arc will be the "original Arc" (i.e. cloning is forbidden), then it doesn't need to be an (Also, if the "original Arc" needs to be the owner, then you either need to Box it or Pin it, so that its address is stable.) Perhaps I would understand better if you could explain what advantage this approach has compared to the original code which used a QCellOwner. |
The |
If you try to code up the |
The code as above is going to work. And the data inside the In fact, the fn get_inner(&self) -> &T {
self.ro(&self.inner)
} The fn mut_inner(&mut self) -> &mut T {
self.rw(&mut self.inner)
} because fn mut_inner(&mut self) -> &mut T {
self.rw(&mut self.inner.clone())
} because the cloned |
The idea seems (probably) sound to me. But it might be a bit much new API for fairly little benefit (saving a single allocation). It’s also quite |
I can see that you can put an owner in So this would be equivalent to putting a If this was going to be made into a general-purpose owner type, it's not necessary to use Really the ideal situation would be to keep a Anyway, I think ArcOwner and ArcCell as I've described are too special-purpose to add to this crate. I can't think of any use apart from this work-around for not being able to store multiple vtables in any other way. Or can you see a more general-purpose way of implementing this that might be useful for other things? |
The original We do understand if this would be a better fit for a separate crate. |
It's hard to make APIs like these generic. Something that could support |
Personally I'd skip straight to the desired end-point, i.e. try to store vtable pointers directly. I had a quick look to see if there had been any progress, and actually yes there has! Simon Sapin's RFC proposal was accepted last year. Discussion about the implementation is progressing here and there seems to be a preliminary implementation here. So maybe you can implement something using this crate. If it's of interest, my own code in Stakker that deconstructs and reconstructs fat pointers is here. |
We can't think of a way to carry |
honestly closing this as we believe it's handled by #37 / |
We don't suppose it'd be possible to have something along these lines?
The main use-case would be the same as #16 except without a separate "owner".
The text was updated successfully, but these errors were encountered: