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 Borrow<T> and BorrowMut<T> for Box<T: ?Sized> #26122

Merged
merged 1 commit into from
Jun 11, 2015

Conversation

bluss
Copy link
Member

@bluss bluss commented Jun 9, 2015

Implement Borrow and BorrowMut for Box<T: ?Sized>

@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 @nikomatsakis (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. 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.

@bluss
Copy link
Member Author

bluss commented Jun 9, 2015

r? @aturon

This change seems logical, it allows the Box<[T]> analogue of Vec<T> among other things.

Question is of course, if it is a breaking change in any way, or if it's simple to introduce?

@rust-highfive rust-highfive assigned aturon and unassigned nikomatsakis Jun 9, 2015
@bluss bluss added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jun 9, 2015
@alexcrichton alexcrichton added the I-needs-decision Issue: In need of a decision. label Jun 9, 2015
@alexcrichton
Copy link
Member

I would be ok with these trait implementations, but a recent change to add a AsRef implementation to a core pointer type ended up causing a regression, so I'm somewhat hesitant about this.

I believe, however, that borrow and borrow_mut are rarer inherent methods, so I think this would be ok.

@brson brson added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jun 9, 2015
@brson
Copy link
Contributor

brson commented Jun 9, 2015

I'll run this through crater.

Nominating since it's regression-prone, so better to get it out sooner?

@aspiwack
Copy link

aspiwack commented Jun 9, 2015

I guess that if you have a x:Box<A> with A:Borrow<B>, then x.borrow() will be &A instead of &B just like in #26096 above.

At any rate, I precipitated this pull request by enquiring about Box<A> not implementing Borrow<A> on irc. In my intuition, Box and Rc are very similar, and I don't see any reason for them not to implement the same trait (apart from the obvious ones). Was that a design choice?

@bluss
Copy link
Member Author

bluss commented Jun 9, 2015

It's a breaking change but a minor change. I expected no trouble, but I understand the situation is the same. I think for our Map collections it can't break anything, it will only allow more types to use .get().

@brson Bringing out crater is great, but I didn't think this was such high stakes 😄

@alexcrichton
Copy link
Member

triage: beta-accepted pending merging plus a crater run

@alexcrichton alexcrichton added beta-accepted Accepted for backporting to the compiler in the beta channel. and removed I-needs-decision Issue: In need of a decision. labels Jun 9, 2015
@brson
Copy link
Contributor

brson commented Jun 9, 2015

@bluss
Copy link
Member Author

bluss commented Jun 9, 2015

@brson 998 unknown crates though?

@brson
Copy link
Contributor

brson commented Jun 9, 2015

@bluss Ugh, idk what happened. I'll run it again.

@brson
Copy link
Contributor

brson commented Jun 10, 2015

OK, now it's run, still looks good https://gist.github.com/brson/1e14d7129c7d3c770b52

@bluss
Copy link
Member Author

bluss commented Jun 10, 2015

Yes, no impact whatsoever on crater, great!

@alexcrichton
Copy link
Member

@bors: r+ 4fdb4cf

Thanks @brson!

bors added a commit that referenced this pull request Jun 11, 2015
Implement Borrow<T> and BorrowMut<T> for Box<T: ?Sized>
@bors
Copy link
Contributor

bors commented Jun 11, 2015

⌛ Testing commit 4fdb4cf with merge 2fbbd54...

@bors bors merged commit 4fdb4cf into rust-lang:master Jun 11, 2015
@bluss bluss deleted the borrow-box branch June 11, 2015 08:51
@alexcrichton alexcrichton removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jun 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. 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.

8 participants