Implement <Rc>::downcast by bluss · Pull Request #44273 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation15 Commits2 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
- Implement
<Rc<Any>>::downcast::<T>
- New unstable method. Works just like Box, but for Rc.
- Any has two cases for its methods: Any and Any + Send; Rc is never Send, so that case is skipped for Rc.
- Motivation for being a method with self is to match Box and there is no user-supplied type; the inner type is Any and downcast does not conflict with any method of Any.
- Arc was skipped because Any itself has no downcast for the case that makes most sense: Any + Send + Sync
r? @sfackler
(rust_highfive has picked a reviewer for you, use r? to override)
I'll probably revise this -- the pointer math in from_raw does not optimize out as it should
Arc is skipped because Any itself has no downcast for the case that makes most sense: Any + Send + Sync
Why we don't implement downcast for Any + Send + Sync
? Other than it isn't terribly necessary.
Implement downcast the like it exists for Box.
The implementation avoids using into_raw/from_raw, because the pointer arithmetic which should cancel does not seem to optimize out at the moment.
Since Rc is never Send, only Rc and not Rc<Any + Send> implements downcast.
bluss changed the title
Implement <Rc>::downcast and generalize Rc::into_raw Implement <Rc>::downcast
I pushed a new version with a more direct implementation, because the pointer arithmetic of using into_raw/from_raw did not optimize out. (playground demo for that)
@kennytm I'm not sure, there are only four combinations of Any and Send, Sync, so it's simple to cover them all, but a bit confusing in the API doc.
sfackler added the T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
label
This seems reasonable to me.
@rfcbot fcp merge
Team member @sfackler has proposed to merge this. The next step is review by the rest of the tagged teams:
No concerns currently listed.
Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
See this document for info about what commands tagged team members can give me.
🔔 This is now entering its final comment period, as per the review above. 🔔
📌 Commit 758a0ce has been approved by alexcrichton
alexcrichton added S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed S-waiting-on-team
Status: Awaiting decision from the relevant subteam (see the T- label).
labels
@bors: r-
oh actually, @bluss mind filing a tracking issue for this and updating the PR with that number?
bluss mentioned this pull request
Sure, updated with tracking issue #44608
📌 Commit 3a39d95 has been approved by alexcrichton
alexcrichton added a commit to alexcrichton/rust that referenced this pull request
Implement <Rc>::downcast
- Implement
<Rc<Any>>::downcast::<T>
- New unstable method. Works just like Box<Any>, but for Rc.
- Any has two cases for its methods: Any and Any + Send; Rc is never Send, so that case is skipped for Rc.
- Motivation for being a method with self is to match Box and there is no user-supplied type; the inner type is Any and downcast does not conflict with any method of Any.
- Arc was skipped because Any itself has no downcast for the case that makes most sense: Any + Send + Sync
frewsxcv added a commit to frewsxcv/rust that referenced this pull request
Implement <Rc>::downcast
- Implement
<Rc<Any>>::downcast::<T>
- New unstable method. Works just like Box<Any>, but for Rc.
- Any has two cases for its methods: Any and Any + Send; Rc is never Send, so that case is skipped for Rc.
- Motivation for being a method with self is to match Box and there is no user-supplied type; the inner type is Any and downcast does not conflict with any method of Any.
- Arc was skipped because Any itself has no downcast for the case that makes most sense: Any + Send + Sync
alexcrichton added a commit to alexcrichton/rust that referenced this pull request
Implement <Rc>::downcast
- Implement
<Rc<Any>>::downcast::<T>
- New unstable method. Works just like Box<Any>, but for Rc.
- Any has two cases for its methods: Any and Any + Send; Rc is never Send, so that case is skipped for Rc.
- Motivation for being a method with self is to match Box and there is no user-supplied type; the inner type is Any and downcast does not conflict with any method of Any.
- Arc was skipped because Any itself has no downcast for the case that makes most sense: Any + Send + Sync
bors added a commit that referenced this pull request
Rollup of 19 pull requests
- Successful merges: #44273, #44356, #44395, #44531, #44537, #44542, #44560, #44567, #44574, #44577, #44586, #44589, #44590, #44593, #44598, #44606, #44609, #44616, #44631
- Failed merges:
bluss deleted the rc-downcast branch
Labels
In the final comment period and will be merged soon unless new substantive objections are raised.
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Relevant to the library API team, which will review and decide on the PR/issue.