Skip to content

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

Merged
bors merged 1 commit intorust-lang:masterfrom
alexcrichton:try-borrow
Feb 3, 2015
Merged

std: Deprecate RefCell::{try_borrow, try_borrow_mut}#21854
bors merged 1 commit intorust-lang:masterfrom
alexcrichton:try-borrow

Conversation

@alexcrichton
Copy link
Copy Markdown
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
Copy Markdown
Contributor

r? @aturon

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

@aturon
Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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.

lnicola pushed a commit to lnicola/rust that referenced this pull request Mar 23, 2026
…rgan

internal: Remove clone_for_update from apply_demorgan
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