Skip to content

Commit 8a26266

Browse files
committed
Change Mut::map to Mut::with
1 parent bb39cc3 commit 8a26266

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

src/libstd/mutable.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<T> Mut<T> {
118118
///
119119
/// Fails if the value is currently mutably borrowed.
120120
#[inline]
121-
pub fn map<U>(&self, blk: |&T| -> U) -> U {
121+
pub fn with<U>(&self, blk: |&T| -> U) -> U {
122122
let ptr = self.borrow();
123123
blk(ptr.get())
124124
}
@@ -129,7 +129,7 @@ impl<T> Mut<T> {
129129
///
130130
/// Fails if the value is currently borrowed.
131131
#[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 {
133133
let mut ptr = self.borrow_mut();
134134
blk(ptr.get())
135135
}
@@ -260,39 +260,39 @@ mod test {
260260
}
261261

262262
#[test]
263-
fn map_ok() {
263+
fn with_ok() {
264264
let x = Mut::new(0);
265-
assert_eq!(1, x.map(|x| *x+1));
265+
assert_eq!(1, x.with(|x| *x+1));
266266
}
267267

268268
#[test]
269269
#[should_fail]
270-
fn mut_borrow_map() {
270+
fn mut_borrow_with() {
271271
let x = Mut::new(0);
272272
let _b1 = x.borrow_mut();
273-
x.map(|x| *x+1);
273+
x.with(|x| *x+1);
274274
}
275275

276276
#[test]
277-
fn borrow_map() {
277+
fn borrow_with() {
278278
let x = Mut::new(0);
279279
let _b1 = x.borrow();
280-
assert_eq!(1, x.map(|x| *x+1));
280+
assert_eq!(1, x.with(|x| *x+1));
281281
}
282282

283283
#[test]
284-
fn map_mut_ok() {
284+
fn with_mut_ok() {
285285
let x = Mut::new(0);
286-
x.map_mut(|x| *x += 1);
286+
x.with_mut(|x| *x += 1);
287287
let b = x.borrow();
288288
assert_eq!(1, *b.get());
289289
}
290290

291291
#[test]
292292
#[should_fail]
293-
fn borrow_map_mut() {
293+
fn borrow_with_mut() {
294294
let x = Mut::new(0);
295295
let _b = x.borrow();
296-
x.map_mut(|x| *x += 1);
296+
x.with_mut(|x| *x += 1);
297297
}
298298
}

src/libstd/rc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,20 @@ mod test_rc {
111111
fn test_clone() {
112112
let x = Rc::from_send(Mut::new(5));
113113
let y = x.clone();
114-
do x.borrow().map_mut |inner| {
114+
do x.borrow().with_mut |inner| {
115115
*inner = 20;
116116
}
117-
assert_eq!(y.borrow().map(|v| *v), 20);
117+
assert_eq!(y.borrow().with(|v| *v), 20);
118118
}
119119

120120
#[test]
121121
fn test_deep_clone() {
122122
let x = Rc::from_send(Mut::new(5));
123123
let y = x.deep_clone();
124-
do x.borrow().map_mut |inner| {
124+
do x.borrow().with_mut |inner| {
125125
*inner = 20;
126126
}
127-
assert_eq!(y.borrow().map(|v| *v), 5);
127+
assert_eq!(y.borrow().with(|v| *v), 5);
128128
}
129129

130130
#[test]

src/libstd/rt/comm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ impl<T: Send> GenericPort<T> for Port<T> {
506506

507507
impl<T: Send> Peekable<T> for Port<T> {
508508
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())
510510
}
511511
}
512512

@@ -517,7 +517,7 @@ impl<T: Send> Peekable<T> for Port<T> {
517517
impl<'self, T: Send> SelectInner for &'self Port<T> {
518518
#[inline]
519519
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() }
521521
}
522522

523523
#[inline]
@@ -528,7 +528,7 @@ impl<'self, T: Send> SelectInner for &'self Port<T> {
528528

529529
#[inline]
530530
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() }
532532
}
533533
}
534534

0 commit comments

Comments
 (0)