We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a9c7feb commit f0b3c02Copy full SHA for f0b3c02
src/libcore/cell.rs
@@ -1101,13 +1101,13 @@ struct BorrowRef<'b> {
1101
impl<'b> BorrowRef<'b> {
1102
#[inline]
1103
fn new(borrow: &'b Cell<BorrowFlag>) -> Option<BorrowRef<'b>> {
1104
- let b = borrow.get();
1105
- if is_writing(b) || b == isize::max_value() {
+ let b = borrow.get().wrapping_add(1);
+ if !is_reading(b) {
1106
// If there's currently a writing borrow, or if incrementing the
1107
// refcount would overflow into a writing borrow.
1108
None
1109
} else {
1110
- borrow.set(b + 1);
+ borrow.set(b);
1111
Some(BorrowRef { borrow })
1112
}
1113
0 commit comments