From 8a26266f6586f765ebdfbc0304e4976bfff28895 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sat, 16 Nov 2013 11:19:25 -0800 Subject: Change Mut::map to Mut::with --- src/libstd/mutable.rs | 24 ++++++++++++------------ src/libstd/rc.rs | 8 ++++---- src/libstd/rt/comm.rs | 6 +++--- 3 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/mutable.rs b/src/libstd/mutable.rs index c343e8734cb..98177b3cdf5 100644 --- a/src/libstd/mutable.rs +++ b/src/libstd/mutable.rs @@ -118,7 +118,7 @@ impl Mut { /// /// Fails if the value is currently mutably borrowed. #[inline] - pub fn map(&self, blk: |&T| -> U) -> U { + pub fn with(&self, blk: |&T| -> U) -> U { let ptr = self.borrow(); blk(ptr.get()) } @@ -129,7 +129,7 @@ impl Mut { /// /// Fails if the value is currently borrowed. #[inline] - pub fn map_mut(&self, blk: |&mut T| -> U) -> U { + pub fn with_mut(&self, blk: |&mut T| -> U) -> U { let mut ptr = self.borrow_mut(); blk(ptr.get()) } @@ -260,39 +260,39 @@ mod test { } #[test] - fn map_ok() { + fn with_ok() { let x = Mut::new(0); - assert_eq!(1, x.map(|x| *x+1)); + assert_eq!(1, x.with(|x| *x+1)); } #[test] #[should_fail] - fn mut_borrow_map() { + fn mut_borrow_with() { let x = Mut::new(0); let _b1 = x.borrow_mut(); - x.map(|x| *x+1); + x.with(|x| *x+1); } #[test] - fn borrow_map() { + fn borrow_with() { let x = Mut::new(0); let _b1 = x.borrow(); - assert_eq!(1, x.map(|x| *x+1)); + assert_eq!(1, x.with(|x| *x+1)); } #[test] - fn map_mut_ok() { + fn with_mut_ok() { let x = Mut::new(0); - x.map_mut(|x| *x += 1); + x.with_mut(|x| *x += 1); let b = x.borrow(); assert_eq!(1, *b.get()); } #[test] #[should_fail] - fn borrow_map_mut() { + fn borrow_with_mut() { let x = Mut::new(0); let _b = x.borrow(); - x.map_mut(|x| *x += 1); + x.with_mut(|x| *x += 1); } } diff --git a/src/libstd/rc.rs b/src/libstd/rc.rs index 2ffdf91ba2f..4cb2c792194 100644 --- a/src/libstd/rc.rs +++ b/src/libstd/rc.rs @@ -111,20 +111,20 @@ mod test_rc { fn test_clone() { let x = Rc::from_send(Mut::new(5)); let y = x.clone(); - do x.borrow().map_mut |inner| { + do x.borrow().with_mut |inner| { *inner = 20; } - assert_eq!(y.borrow().map(|v| *v), 20); + assert_eq!(y.borrow().with(|v| *v), 20); } #[test] fn test_deep_clone() { let x = Rc::from_send(Mut::new(5)); let y = x.deep_clone(); - do x.borrow().map_mut |inner| { + do x.borrow().with_mut |inner| { *inner = 20; } - assert_eq!(y.borrow().map(|v| *v), 5); + assert_eq!(y.borrow().with(|v| *v), 5); } #[test] diff --git a/src/libstd/rt/comm.rs b/src/libstd/rt/comm.rs index 077e9ba195b..7441d0d3edc 100644 --- a/src/libstd/rt/comm.rs +++ b/src/libstd/rt/comm.rs @@ -506,7 +506,7 @@ impl GenericPort for Port { impl Peekable for Port { fn peek(&self) -> bool { - self.next.map_mut(|p| p.get_mut_ref().peek()) + self.next.with_mut(|p| p.get_mut_ref().peek()) } } @@ -517,7 +517,7 @@ impl Peekable for Port { impl<'self, T: Send> SelectInner for &'self Port { #[inline] fn optimistic_check(&mut self) -> bool { - do self.next.map_mut |pone| { pone.get_mut_ref().optimistic_check() } + do self.next.with_mut |pone| { pone.get_mut_ref().optimistic_check() } } #[inline] @@ -528,7 +528,7 @@ impl<'self, T: Send> SelectInner for &'self Port { #[inline] fn unblock_from(&mut self) -> bool { - do self.next.map_mut |pone| { pone.get_mut_ref().unblock_from() } + do self.next.with_mut |pone| { pone.get_mut_ref().unblock_from() } } } -- cgit 1.4.1-3-g733a5