diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-02-01 18:53:47 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-02-01 18:58:14 -0800 |
| commit | deed093a38243ced1f52927ebf7511c099a3bf36 (patch) | |
| tree | 0e094bb05ec36036c344b0cb1135b165b2037166 /src/libcoretest | |
| parent | ca4b9674c26c1de07a2042cb68e6a062d7184cef (diff) | |
| download | rust-deed093a38243ced1f52927ebf7511c099a3bf36.tar.gz rust-deed093a38243ced1f52927ebf7511c099a3bf36.zip | |
std: Deprecate RefCell::{try_borrow, try_borrow_mut}
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.
Diffstat (limited to 'src/libcoretest')
| -rw-r--r-- | src/libcoretest/cell.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libcoretest/cell.rs b/src/libcoretest/cell.rs index 5815dbc0acc..8939bd61fe4 100644 --- a/src/libcoretest/cell.rs +++ b/src/libcoretest/cell.rs @@ -60,6 +60,7 @@ fn no_mut_then_imm_borrow() { let x = RefCell::new(0); let _b1 = x.borrow_mut(); assert!(x.try_borrow().is_none()); + assert_eq!(x.borrow_state(), BorrowState::Writing); } #[test] @@ -67,13 +68,16 @@ fn no_imm_then_borrow_mut() { let x = RefCell::new(0); let _b1 = x.borrow(); assert!(x.try_borrow_mut().is_none()); + assert_eq!(x.borrow_state(), BorrowState::Reading); } #[test] fn no_double_borrow_mut() { let x = RefCell::new(0); + assert_eq!(x.borrow_state(), BorrowState::Unused); let _b1 = x.borrow_mut(); assert!(x.try_borrow_mut().is_none()); + assert_eq!(x.borrow_state(), BorrowState::Writing); } #[test] |
