@@ -173,28 +173,6 @@ impl<T> RefCell<T> {
173
173
}
174
174
}
175
175
176
- /// Immutably borrows the wrapped value and applies `blk` to it.
177
- ///
178
- /// # Failure
179
- ///
180
- /// Fails if the value is currently mutably borrowed.
181
- #[ inline]
182
- pub fn with < U > ( & self , blk: |& T | -> U ) -> U {
183
- let ptr = self . borrow ( ) ;
184
- blk ( ptr. get ( ) )
185
- }
186
-
187
- /// Mutably borrows the wrapped value and applies `blk` to it.
188
- ///
189
- /// # Failure
190
- ///
191
- /// Fails if the value is currently borrowed.
192
- #[ inline]
193
- pub fn with_mut < U > ( & self , blk: |& mut T | -> U ) -> U {
194
- let mut ptr = self . borrow_mut ( ) ;
195
- blk ( ptr. get ( ) )
196
- }
197
-
198
176
/// Sets the value, replacing what was there.
199
177
///
200
178
/// # Failure
@@ -372,43 +350,6 @@ mod test {
372
350
assert ! ( x. try_borrow_mut( ) . is_none( ) ) ;
373
351
}
374
352
375
- #[ test]
376
- fn with_ok ( ) {
377
- let x = RefCell :: new ( 0 ) ;
378
- assert_eq ! ( 1 , x. with( |x| * x+1 ) ) ;
379
- }
380
-
381
- #[ test]
382
- #[ should_fail]
383
- fn mut_borrow_with ( ) {
384
- let x = RefCell :: new ( 0 ) ;
385
- let _b1 = x. borrow_mut ( ) ;
386
- x. with ( |x| * x+1 ) ;
387
- }
388
-
389
- #[ test]
390
- fn borrow_with ( ) {
391
- let x = RefCell :: new ( 0 ) ;
392
- let _b1 = x. borrow ( ) ;
393
- assert_eq ! ( 1 , x. with( |x| * x+1 ) ) ;
394
- }
395
-
396
- #[ test]
397
- fn with_mut_ok ( ) {
398
- let x = RefCell :: new ( 0 ) ;
399
- x. with_mut ( |x| * x += 1 ) ;
400
- let b = x. borrow ( ) ;
401
- assert_eq ! ( 1 , * b. get( ) ) ;
402
- }
403
-
404
- #[ test]
405
- #[ should_fail]
406
- fn borrow_with_mut ( ) {
407
- let x = RefCell :: new ( 0 ) ;
408
- let _b = x. borrow ( ) ;
409
- x. with_mut ( |x| * x += 1 ) ;
410
- }
411
-
412
353
#[ test]
413
354
#[ should_fail]
414
355
fn discard_doesnt_unborrow ( ) {
0 commit comments