]> git.lizzy.rs Git - rust.git/commitdiff
Change Mut::map to Mut::with
authorSteven Fackler <sfackler@gmail.com>
Sat, 16 Nov 2013 19:19:25 +0000 (11:19 -0800)
committerSteven Fackler <sfackler@gmail.com>
Sat, 23 Nov 2013 05:19:53 +0000 (21:19 -0800)
src/libstd/mutable.rs
src/libstd/rc.rs
src/libstd/rt/comm.rs

index c343e8734cb8c052c36800e30baab401582902a2..98177b3cdf5767b8c57a5c5a53773bba65c30259 100644 (file)
@@ -118,7 +118,7 @@ pub fn borrow_mut<'a>(&'a self) -> RefMut<'a, T> {
     ///
     /// Fails if the value is currently mutably borrowed.
     #[inline]
-    pub fn map<U>(&self, blk: |&T| -> U) -> U {
+    pub fn with<U>(&self, blk: |&T| -> U) -> U {
         let ptr = self.borrow();
         blk(ptr.get())
     }
@@ -129,7 +129,7 @@ pub fn map<U>(&self, blk: |&T| -> U) -> U {
     ///
     /// Fails if the value is currently borrowed.
     #[inline]
-    pub fn map_mut<U>(&self, blk: |&mut T| -> U) -> U {
+    pub fn with_mut<U>(&self, blk: |&mut T| -> U) -> U {
         let mut ptr = self.borrow_mut();
         blk(ptr.get())
     }
@@ -260,39 +260,39 @@ fn double_borrow_single_release_no_borrow_mut() {
     }
 
     #[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);
     }
 }
index 2ffdf91ba2fd168bc39f60e0d1644c838ec709bd..4cb2c79219482eb9e7c79029ce330b825ac5e662 100644 (file)
@@ -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]
index 077e9ba195bbc004634367fddf7aa203d0f3fef2..7441d0d3edcca4d14883d0c5641e51d10d21866c 100644 (file)
@@ -506,7 +506,7 @@ fn try_recv(&self) -> Option<T> {
 
 impl<T: Send> Peekable<T> for Port<T> {
     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 @@ fn peek(&self) -> bool {
 impl<'self, T: Send> SelectInner for &'self Port<T> {
     #[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 @@ fn block_on(&mut self, sched: &mut Scheduler, task: BlockedTask) -> bool {
 
     #[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() }
     }
 }