Skip to content
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

No way to serialize Weak pointers #186

Closed
erickt opened this issue Nov 25, 2015 · 7 comments
Closed

No way to serialize Weak pointers #186

erickt opened this issue Nov 25, 2015 · 7 comments
Assignees

Comments

@erickt
Copy link
Member

erickt commented Nov 25, 2015

As mentioned on reddit. Open question: What do we do if the value the Weak pointer is pointing at has been destroyed? Should we serialize them as an Option pointer?

@erickt
Copy link
Member Author

erickt commented Nov 25, 2015

It's also not clear what we should do for deserialization.

@oli-obk
Copy link
Member

oli-obk commented Nov 25, 2015

I'd serialize it as an Option pointer and during deserialization, in case it's None, just create an Rc, make a Weak from that and drop the Rc.

@erickt
Copy link
Member Author

erickt commented Dec 8, 2015

@oli-obk: I suppose that would work, but it seems sad that we wouldn't actually be able to deserialize these weak types. I wonder if a better idea would be to get a impl Default implemented for Weak types, that defaults to it not being defined.

@shahn
Copy link

shahn commented Dec 8, 2015

I think it doesn't really make sense to put more time into this until #194 is resolved somehow. For Weak pointers the failure modes mentioned in #194 are even worse.

Nevertheless, getting a default impl for Weak into rust seems smart.

@apasel422
Copy link

rust-lang/rust#30467 added a Weak::new method, though it is unstable.

@oli-obk
Copy link
Member

oli-obk commented Jun 29, 2016

Weak::new is now (1.10) stable: rust-lang/rust#30425 (comment)

@shahn
Copy link

shahn commented Jun 29, 2016

My point about #194 being unresolved remains I'm afraid, tho of course I'm happy Weak::new is stable now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants