Skip to content

std: Deprecate RefCell::{try_borrow, try_borrow_mut} #21854

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

Merged
merged 1 commit into from
Feb 3, 2015

Conversation

alexcrichton
Copy link
Member

The existence of these two functions is at odds with our current error
conventions
which recommend that panicking and Result-like
variants should not be provided together.

This commit adds a new borrow_state function returning a BorrowState enum to
RefCell which serves as a replacemnt for the try_borrow and try_borrow_mut
functions.

The existence of these two functions is at odds with our current [error
conventions][conventions] which recommend that panicking and `Result`-like
variants should not be provided together.

[conventions]: https://github.com/rust-lang/rfcs/blob/master/text/0236-error-conventions.md#do-not-provide-both-result-and-fail-variants

This commit adds a new `borrow_state` function returning a `BorrowState` enum to
`RefCell` which serves as a replacemnt for the `try_borrow` and `try_borrow_mut`
functions.
@rust-highfive
Copy link
Contributor

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@aturon
Copy link
Member

aturon commented Feb 2, 2015

@bors: r+ deed093

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Feb 2, 2015
The existence of these two functions is at odds with our current [error
conventions][conventions] which recommend that panicking and `Result`-like
variants should not be provided together.

[conventions]: https://github.com/rust-lang/rfcs/blob/master/text/0236-error-conventions.md#do-not-provide-both-result-and-fail-variants

This commit adds a new `borrow_state` function returning a `BorrowState` enum to
`RefCell` which serves as a replacemnt for the `try_borrow` and `try_borrow_mut`
functions.
@bors bors merged commit deed093 into rust-lang:master Feb 3, 2015
@alexcrichton alexcrichton deleted the try-borrow branch February 3, 2015 06:44
@tbu-
Copy link
Contributor

tbu- commented Feb 3, 2015

This makes it a lot more unergonic to use and is not mentioned in the linked-to RFC. In the RFC it says that RefCell and Channel are the current exceptions.

@alexcrichton
Copy link
Member Author

@tbu- we've been backpedaling on there being any exceptions to the rule by moving channel methods entirely to Result and this was the final nail in the coffin (to stop having RefCell be the only exception).

@bluss
Copy link
Member

bluss commented Feb 5, 2015

I'm sad, it makes RefCell even more cumbersome to use, and it's for example harder to provide a custom panic message. I'd opt for just using .borrow_mut() instead now sadly. Using Option would feel more rustic.

This is not like channel because there is no option- or result-returning method left.

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

Successfully merging this pull request may close these issues.

6 participants