From f4083a22451692b9ae360f3d12bfb8cb52b096e4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 21 Apr 2014 22:15:42 -0700 Subject: 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] --- src/libcollections/bitv.rs | 2 +- src/libcollections/ringbuf.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libcollections') diff --git a/src/libcollections/bitv.rs b/src/libcollections/bitv.rs index 6326f83b497..13180cdfa5b 100644 --- a/src/libcollections/bitv.rs +++ b/src/libcollections/bitv.rs @@ -632,7 +632,7 @@ impl<'a> RandomAccessIterator for Bits<'a> { } #[inline] - fn idx(&self, index: uint) -> Option { + fn idx(&mut self, index: uint) -> Option { if index >= self.indexable() { None } else { diff --git a/src/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs index 19dc2d2ae58..9204a9ca400 100644 --- a/src/libcollections/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -272,7 +272,7 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> { fn indexable(&self) -> uint { self.rindex - self.index } #[inline] - fn idx(&self, j: uint) -> Option<&'a T> { + fn idx(&mut self, j: uint) -> Option<&'a T> { if j >= self.indexable() { None } else { -- cgit 1.4.1-3-g733a5