archery icon indicating copy to clipboard operation
archery copied to clipboard

Support weak pointers

Open glebpom opened this issue 4 years ago • 4 comments

Thanks for your work on this crate!

Are there any plans to support Weak pointers?

glebpom avatar Apr 24 '20 15:04 glebpom

Hi.

Definitely something I wanted to do. I might pick that up when I have time. Meanwhile if you or anyone else wants to work on that just let me know.

orium avatar Apr 26 '20 17:04 orium

I was looking at the code a bit, and it seems that it's not clear how to implement it exactly in terms of traits and associated types.

The first idea which comes to my mind is to add the WeakPointerKind trait and an associated type WeakPointer (restricted to WeakPointerKind trait) to SharedPointerKind.

What do you think?

glebpom avatar Apr 27 '20 09:04 glebpom

Yes, I think that will work. It is pretty much analogous to the SharedPointer and SharedPointerKind.

However, to implement WeakPointer::upgrade() will be a bit tricker, but I think it can be done, but even without that method having a weak pointer already adds a lot of value.

orium avatar Apr 27 '20 15:04 orium