about summary refs log tree commit diff
path: root/src/libstd/slice.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-04-21 22:15:42 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-04-23 10:03:43 -0700
commitf4083a22451692b9ae360f3d12bfb8cb52b096e4 (patch)
tree5def1ac72e0ed4208f3995fdf609e8ac8539c65f /src/libstd/slice.rs
parent159a10da4c15e5d34e00d4018b352573cec7918f (diff)
downloadrust-f4083a22451692b9ae360f3d12bfb8cb52b096e4.tar.gz
rust-f4083a22451692b9ae360f3d12bfb8cb52b096e4.zip
std: Change RandomAccessIterator to use `&mut self`
Many iterators go through a closure when dealing with the `idx` method, which
are invalid after the previous change (closures cannot be invoked through a `&`
pointer). This commit alters the `fn idx` method on the RandomAccessIterator
to take `&mut self` rather than `&self`.

[breaking-change]
Diffstat (limited to 'src/libstd/slice.rs')
-rw-r--r--src/libstd/slice.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libstd/slice.rs b/src/libstd/slice.rs
index 6c55195e627..309ea8623e5 100644
--- a/src/libstd/slice.rs
+++ b/src/libstd/slice.rs
@@ -489,7 +489,7 @@ impl<'a, T> RandomAccessIterator<&'a [T]> for Chunks<'a, T> {
     }
 
     #[inline]
-    fn idx(&self, index: uint) -> Option<&'a [T]> {
+    fn idx(&mut self, index: uint) -> Option<&'a [T]> {
         if index < self.indexable() {
             let lo = index * self.size;
             let mut hi = lo + self.size;
@@ -2095,7 +2095,7 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> {
     }
 
     #[inline]
-    fn idx(&self, index: uint) -> Option<&'a T> {
+    fn idx(&mut self, index: uint) -> Option<&'a T> {
         unsafe {
             if index < self.indexable() {
                 transmute(self.ptr.offset(index as int))