File tree Expand file tree Collapse file tree 3 files changed +19
-19
lines changed Expand file tree Collapse file tree 3 files changed +19
-19
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ impl<T> Mut<T> {
118
118
///
119
119
/// Fails if the value is currently mutably borrowed.
120
120
#[ inline]
121
- pub fn map < U > ( & self , blk: |& T | -> U ) -> U {
121
+ pub fn with < U > ( & self , blk: |& T | -> U ) -> U {
122
122
let ptr = self . borrow ( ) ;
123
123
blk ( ptr. get ( ) )
124
124
}
@@ -129,7 +129,7 @@ impl<T> Mut<T> {
129
129
///
130
130
/// Fails if the value is currently borrowed.
131
131
#[ inline]
132
- pub fn map_mut < U > ( & self , blk: |& mut T | -> U ) -> U {
132
+ pub fn with_mut < U > ( & self , blk: |& mut T | -> U ) -> U {
133
133
let mut ptr = self . borrow_mut ( ) ;
134
134
blk ( ptr. get ( ) )
135
135
}
@@ -260,39 +260,39 @@ mod test {
260
260
}
261
261
262
262
#[ test]
263
- fn map_ok ( ) {
263
+ fn with_ok ( ) {
264
264
let x = Mut :: new ( 0 ) ;
265
- assert_eq ! ( 1 , x. map ( |x| * x+1 ) ) ;
265
+ assert_eq ! ( 1 , x. with ( |x| * x+1 ) ) ;
266
266
}
267
267
268
268
#[ test]
269
269
#[ should_fail]
270
- fn mut_borrow_map ( ) {
270
+ fn mut_borrow_with ( ) {
271
271
let x = Mut :: new ( 0 ) ;
272
272
let _b1 = x. borrow_mut ( ) ;
273
- x. map ( |x| * x+1 ) ;
273
+ x. with ( |x| * x+1 ) ;
274
274
}
275
275
276
276
#[ test]
277
- fn borrow_map ( ) {
277
+ fn borrow_with ( ) {
278
278
let x = Mut :: new ( 0 ) ;
279
279
let _b1 = x. borrow ( ) ;
280
- assert_eq ! ( 1 , x. map ( |x| * x+1 ) ) ;
280
+ assert_eq ! ( 1 , x. with ( |x| * x+1 ) ) ;
281
281
}
282
282
283
283
#[ test]
284
- fn map_mut_ok ( ) {
284
+ fn with_mut_ok ( ) {
285
285
let x = Mut :: new ( 0 ) ;
286
- x. map_mut ( |x| * x += 1 ) ;
286
+ x. with_mut ( |x| * x += 1 ) ;
287
287
let b = x. borrow ( ) ;
288
288
assert_eq ! ( 1 , * b. get( ) ) ;
289
289
}
290
290
291
291
#[ test]
292
292
#[ should_fail]
293
- fn borrow_map_mut ( ) {
293
+ fn borrow_with_mut ( ) {
294
294
let x = Mut :: new ( 0 ) ;
295
295
let _b = x. borrow ( ) ;
296
- x. map_mut ( |x| * x += 1 ) ;
296
+ x. with_mut ( |x| * x += 1 ) ;
297
297
}
298
298
}
Original file line number Diff line number Diff line change @@ -111,20 +111,20 @@ mod test_rc {
111
111
fn test_clone( ) {
112
112
let x = Rc :: from_send ( Mut :: new ( 5 ) ) ;
113
113
let y = x. clone ( ) ;
114
- do x. borrow ( ) . map_mut |inner| {
114
+ do x. borrow ( ) . with_mut |inner| {
115
115
* inner = 20 ;
116
116
}
117
- assert_eq ! ( y. borrow( ) . map ( |v| * v) , 20 ) ;
117
+ assert_eq ! ( y. borrow( ) . with ( |v| * v) , 20 ) ;
118
118
}
119
119
120
120
#[ test]
121
121
fn test_deep_clone( ) {
122
122
let x = Rc :: from_send ( Mut :: new ( 5 ) ) ;
123
123
let y = x. deep_clone ( ) ;
124
- do x. borrow ( ) . map_mut |inner| {
124
+ do x. borrow ( ) . with_mut |inner| {
125
125
* inner = 20 ;
126
126
}
127
- assert_eq ! ( y. borrow( ) . map ( |v| * v) , 5 ) ;
127
+ assert_eq ! ( y. borrow( ) . with ( |v| * v) , 5 ) ;
128
128
}
129
129
130
130
#[ test]
Original file line number Diff line number Diff line change @@ -506,7 +506,7 @@ impl<T: Send> GenericPort<T> for Port<T> {
506
506
507
507
impl < T : Send > Peekable < T > for Port < T > {
508
508
fn peek ( & self ) -> bool {
509
- self . next . map_mut ( |p| p. get_mut_ref ( ) . peek ( ) )
509
+ self . next . with_mut ( |p| p. get_mut_ref ( ) . peek ( ) )
510
510
}
511
511
}
512
512
@@ -517,7 +517,7 @@ impl<T: Send> Peekable<T> for Port<T> {
517
517
impl < ' self , T : Send > SelectInner for & ' self Port < T > {
518
518
#[ inline]
519
519
fn optimistic_check ( & mut self ) -> bool {
520
- do self . next . map_mut |pone| { pone. get_mut_ref ( ) . optimistic_check ( ) }
520
+ do self . next . with_mut |pone| { pone. get_mut_ref ( ) . optimistic_check ( ) }
521
521
}
522
522
523
523
#[ inline]
@@ -528,7 +528,7 @@ impl<'self, T: Send> SelectInner for &'self Port<T> {
528
528
529
529
#[ inline]
530
530
fn unblock_from ( & mut self ) -> bool {
531
- do self . next . map_mut |pone| { pone. get_mut_ref ( ) . unblock_from ( ) }
531
+ do self . next . with_mut |pone| { pone. get_mut_ref ( ) . unblock_from ( ) }
532
532
}
533
533
}
534
534
You can’t perform that action at this time.
0 commit comments