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

Implement Weak::new_downgraded() (#30425) #30467

Merged
merged 7 commits into from Dec 30, 2015
Merged

Implement Weak::new_downgraded() (#30425) #30467

merged 7 commits into from Dec 30, 2015

Conversation

shahn
Copy link
Contributor

@shahn shahn commented Dec 18, 2015

This adds a constructor for a Weak that can never be upgraded. These are
mostly useless, but for example are required when deserializing.

This adds a constructor for a Weak that can never be upgraded. These are
mostly useless, but for example are required when deserializing.
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@brson
Copy link
Contributor

brson commented Dec 18, 2015

cc @rust-lang/libs Is everyone cool with this? Does it need an RFC?

_ptr: Shared::new(Box::into_raw(box RcBox {
strong: Cell::new(0),
weak: Cell::new(1),
value: uninit(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this use core::mem::uninitialized instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixing

@alexcrichton
Copy link
Member

I would probably personally call this Weak::new to stick closer to our existing conventions, but otherwise it seems harmless to me as well.

@apasel422
Copy link
Contributor

Should Arc's Weak have this as well?

@shahn
Copy link
Contributor Author

shahn commented Dec 18, 2015

@alexcrichton The reason I went with a different name was to make it clear that this won't be usable for "normal" code. Happy to defer to you of course, extending PR.

@apasei422 good point! I'll extend the PR.

@alexcrichton alexcrichton added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Dec 18, 2015
@shahn
Copy link
Contributor Author

shahn commented Dec 18, 2015

I'm thinking if everyone likes this branch I should probably rebase & squash it into a single commit?

///
/// use std::sync::Arc;
///
/// let five = Arc::new(5);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Weak::new.

@shahn
Copy link
Contributor Author

shahn commented Dec 19, 2015

I agree wrt the examples, I added them because they were there for Rc::new and Arc::new (where they also only assign a value). Should I update this?

@shahn
Copy link
Contributor Author

shahn commented Dec 20, 2015

I think I addressed all review comments, thanks a bunch. Anything else for me to do except wait while a decision is made?

@brson
Copy link
Contributor

brson commented Dec 28, 2015

@bors r+

@bors
Copy link
Contributor

bors commented Dec 28, 2015

📌 Commit 5b3bdaf has been approved by brson

Manishearth added a commit to Manishearth/rust that referenced this pull request Dec 29, 2015
This adds a constructor for a Weak that can never be upgraded. These are
mostly useless, but for example are required when deserializing.
@bors
Copy link
Contributor

bors commented Dec 30, 2015

⌛ Testing commit 5b3bdaf with merge cb50f54...

@bors
Copy link
Contributor

bors commented Dec 30, 2015

💔 Test failed - auto-linux-64-nopt-t

@sfackler
Copy link
Member

@bors retry

bors added a commit that referenced this pull request Dec 30, 2015
This adds a constructor for a Weak that can never be upgraded. These are
mostly useless, but for example are required when deserializing.
@bors
Copy link
Contributor

bors commented Dec 30, 2015

⌛ Testing commit 5b3bdaf with merge 682cfc5...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants