Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
remove unecessary lifetimes from a bunch of collections code
  • Loading branch information
Gankra committed Feb 5, 2015
1 parent e250fe3 commit 1420ceb
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/libcollections/binary_heap.rs
Expand Up @@ -708,7 +708,7 @@ mod tests {
let iterout = vec![3, 5, 9];
let pq = BinaryHeap::from_vec(data);

let v: Vec<_> = pq.iter().rev().map(|&x| x).collect();
let v: Vec<_> = pq.iter().rev().cloned().collect();
assert_eq!(v, iterout);
}

Expand Down
12 changes: 6 additions & 6 deletions src/libcollections/ring_buf.rs
Expand Up @@ -529,13 +529,13 @@ impl<T> RingBuf<T> {
/// assert_eq!(&buf.iter_mut().collect::<Vec<&mut i32>>()[], b);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> {
pub fn iter_mut(&mut self) -> IterMut<T> {
IterMut {
tail: self.tail,
head: self.head,
cap: self.cap,
ptr: self.ptr,
marker: marker::ContravariantLifetime::<'a>,
marker: marker::ContravariantLifetime,
}
}

Expand All @@ -552,7 +552,7 @@ impl<T> RingBuf<T> {
#[inline]
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn as_slices<'a>(&'a self) -> (&'a [T], &'a [T]) {
pub fn as_slices(&self) -> (&[T], &[T]) {
unsafe {
let contiguous = self.is_contiguous();
let buf = self.buffer_as_slice();
Expand All @@ -572,7 +572,7 @@ impl<T> RingBuf<T> {
#[inline]
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn as_mut_slices<'a>(&'a mut self) -> (&'a mut [T], &'a mut [T]) {
pub fn as_mut_slices(&mut self) -> (&mut [T], &mut [T]) {
unsafe {
let contiguous = self.is_contiguous();
let head = self.head;
Expand Down Expand Up @@ -1584,7 +1584,7 @@ impl<A> Index<usize> for RingBuf<A> {
type Output = A;

#[inline]
fn index<'a>(&'a self, i: &usize) -> &'a A {
fn index(&self, i: &usize) -> &A {
self.get(*i).expect("Out of bounds access")
}
}
Expand All @@ -1594,7 +1594,7 @@ impl<A> IndexMut<usize> for RingBuf<A> {
type Output = A;

#[inline]
fn index_mut<'a>(&'a mut self, i: &usize) -> &'a mut A {
fn index_mut(&mut self, i: &usize) -> &mut A {
self.get_mut(*i).expect("Out of bounds access")
}
}
Expand Down
52 changes: 26 additions & 26 deletions src/libcollections/slice.rs
Expand Up @@ -812,27 +812,27 @@ impl<T> SliceExt for [T] {
}

#[inline]
fn slice<'a>(&'a self, start: usize, end: usize) -> &'a [T] {
fn slice(&self, start: usize, end: usize) -> &[T] {
&self[start .. end]
}

#[inline]
fn slice_from<'a>(&'a self, start: usize) -> &'a [T] {
fn slice_from(&self, start: usize) -> &[T] {
&self[start ..]
}

#[inline]
fn slice_to<'a>(&'a self, end: usize) -> &'a [T] {
fn slice_to(&self, end: usize) -> &[T] {
&self[.. end]
}

#[inline]
fn split_at<'a>(&'a self, mid: usize) -> (&'a [T], &'a [T]) {
fn split_at(&self, mid: usize) -> (&[T], &[T]) {
core_slice::SliceExt::split_at(self, mid)
}

#[inline]
fn iter<'a>(&'a self) -> Iter<'a, T> {
fn iter(&self) -> Iter<T> {
core_slice::SliceExt::iter(self)
}

Expand All @@ -855,42 +855,42 @@ impl<T> SliceExt for [T] {
}

#[inline]
fn windows<'a>(&'a self, size: usize) -> Windows<'a, T> {
fn windows(&self, size: usize) -> Windows<T> {
core_slice::SliceExt::windows(self, size)
}

#[inline]
fn chunks<'a>(&'a self, size: usize) -> Chunks<'a, T> {
fn chunks(&self, size: usize) -> Chunks<T> {
core_slice::SliceExt::chunks(self, size)
}

#[inline]
fn get<'a>(&'a self, index: usize) -> Option<&'a T> {
fn get(&self, index: usize) -> Option<&T> {
core_slice::SliceExt::get(self, index)
}

#[inline]
fn first<'a>(&'a self) -> Option<&'a T> {
fn first(&self) -> Option<&T> {
core_slice::SliceExt::first(self)
}

#[inline]
fn tail<'a>(&'a self) -> &'a [T] {
fn tail(&self) -> &[T] {
core_slice::SliceExt::tail(self)
}

#[inline]
fn init<'a>(&'a self) -> &'a [T] {
fn init(&self) -> &[T] {
core_slice::SliceExt::init(self)
}

#[inline]
fn last<'a>(&'a self) -> Option<&'a T> {
fn last(&self) -> Option<&T> {
core_slice::SliceExt::last(self)
}

#[inline]
unsafe fn get_unchecked<'a>(&'a self, index: usize) -> &'a T {
unsafe fn get_unchecked(&self, index: usize) -> &T {
core_slice::SliceExt::get_unchecked(self, index)
}

Expand All @@ -916,52 +916,52 @@ impl<T> SliceExt for [T] {
}

#[inline]
fn get_mut<'a>(&'a mut self, index: usize) -> Option<&'a mut T> {
fn get_mut(&mut self, index: usize) -> Option<&mut T> {
core_slice::SliceExt::get_mut(self, index)
}

#[inline]
fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
fn as_mut_slice(&mut self) -> &mut [T] {
core_slice::SliceExt::as_mut_slice(self)
}

#[inline]
fn slice_mut<'a>(&'a mut self, start: usize, end: usize) -> &'a mut [T] {
fn slice_mut(&mut self, start: usize, end: usize) -> &mut [T] {
&mut self[start .. end]
}

#[inline]
fn slice_from_mut<'a>(&'a mut self, start: usize) -> &'a mut [T] {
fn slice_from_mut(&mut self, start: usize) -> &mut [T] {
&mut self[start ..]
}

#[inline]
fn slice_to_mut<'a>(&'a mut self, end: usize) -> &'a mut [T] {
fn slice_to_mut(&mut self, end: usize) -> &mut [T] {
&mut self[.. end]
}

#[inline]
fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> {
fn iter_mut(&mut self) -> IterMut<T> {
core_slice::SliceExt::iter_mut(self)
}

#[inline]
fn first_mut<'a>(&'a mut self) -> Option<&'a mut T> {
fn first_mut(&mut self) -> Option<&mut T> {
core_slice::SliceExt::first_mut(self)
}

#[inline]
fn tail_mut<'a>(&'a mut self) -> &'a mut [T] {
fn tail_mut(&mut self) -> &mut [T] {
core_slice::SliceExt::tail_mut(self)
}

#[inline]
fn init_mut<'a>(&'a mut self) -> &'a mut [T] {
fn init_mut(&mut self) -> &mut [T] {
core_slice::SliceExt::init_mut(self)
}

#[inline]
fn last_mut<'a>(&'a mut self) -> Option<&'a mut T> {
fn last_mut(&mut self) -> Option<&mut T> {
core_slice::SliceExt::last_mut(self)
}

Expand All @@ -984,7 +984,7 @@ impl<T> SliceExt for [T] {
}

#[inline]
fn chunks_mut<'a>(&'a mut self, chunk_size: usize) -> ChunksMut<'a, T> {
fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<T> {
core_slice::SliceExt::chunks_mut(self, chunk_size)
}

Expand All @@ -994,7 +994,7 @@ impl<T> SliceExt for [T] {
}

#[inline]
fn split_at_mut<'a>(&'a mut self, mid: usize) -> (&'a mut [T], &'a mut [T]) {
fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
core_slice::SliceExt::split_at_mut(self, mid)
}

Expand All @@ -1004,7 +1004,7 @@ impl<T> SliceExt for [T] {
}

#[inline]
unsafe fn get_unchecked_mut<'a>(&'a mut self, index: usize) -> &'a mut T {
unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T {
core_slice::SliceExt::get_unchecked_mut(self, index)
}

Expand Down
8 changes: 4 additions & 4 deletions src/libcollections/str.rs
Expand Up @@ -464,7 +464,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
#[inline]
#[unstable(feature = "collections",
reason = "this functionality may be moved to libunicode")]
fn nfd_chars<'a>(&'a self) -> Decompositions<'a> {
fn nfd_chars(&self) -> Decompositions {
Decompositions {
iter: self[].chars(),
buffer: Vec::new(),
Expand All @@ -478,7 +478,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
#[inline]
#[unstable(feature = "collections",
reason = "this functionality may be moved to libunicode")]
fn nfkd_chars<'a>(&'a self) -> Decompositions<'a> {
fn nfkd_chars(&self) -> Decompositions {
Decompositions {
iter: self[].chars(),
buffer: Vec::new(),
Expand All @@ -492,7 +492,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
#[inline]
#[unstable(feature = "collections",
reason = "this functionality may be moved to libunicode")]
fn nfc_chars<'a>(&'a self) -> Recompositions<'a> {
fn nfc_chars(&self) -> Recompositions {
Recompositions {
iter: self.nfd_chars(),
state: Composing,
Expand All @@ -507,7 +507,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
#[inline]
#[unstable(feature = "collections",
reason = "this functionality may be moved to libunicode")]
fn nfkc_chars<'a>(&'a self) -> Recompositions<'a> {
fn nfkc_chars(&self) -> Recompositions {
Recompositions {
iter: self.nfkd_chars(),
state: Composing,
Expand Down
8 changes: 4 additions & 4 deletions src/libcollections/string.rs
Expand Up @@ -488,7 +488,7 @@ impl String {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
pub fn as_bytes(&self) -> &[u8] {
&self.vec
}

Expand Down Expand Up @@ -627,7 +627,7 @@ impl String {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub unsafe fn as_mut_vec<'a>(&'a mut self) -> &'a mut Vec<u8> {
pub unsafe fn as_mut_vec(&mut self) -> &mut Vec<u8> {
&mut self.vec
}

Expand Down Expand Up @@ -803,7 +803,7 @@ impl<'a, 'b> PartialEq<CowString<'a>> for &'b str {
impl Str for String {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn as_slice<'a>(&'a self) -> &'a str {
fn as_slice(&self) -> &str {
unsafe { mem::transmute(&*self.vec) }
}
}
Expand Down Expand Up @@ -891,7 +891,7 @@ impl ops::Deref for String {
type Target = str;

#[inline]
fn deref<'a>(&'a self) -> &'a str {
fn deref(&self) -> &str {
unsafe { mem::transmute(&self.vec[]) }
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/libcollections/vec.rs
Expand Up @@ -425,7 +425,7 @@ impl<T> Vec<T> {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
pub fn as_mut_slice(&mut self) -> &mut [T] {
unsafe {
mem::transmute(RawSlice {
data: *self.ptr,
Expand Down Expand Up @@ -737,7 +737,7 @@ impl<T> Vec<T> {
#[inline]
#[unstable(feature = "collections",
reason = "matches collection reform specification, waiting for dust to settle")]
pub fn drain<'a>(&'a mut self) -> Drain<'a, T> {
pub fn drain(&mut self) -> Drain<T> {
unsafe {
let begin = *self.ptr as *const T;
let end = if mem::size_of::<T>() == 0 {
Expand Down Expand Up @@ -1278,7 +1278,7 @@ impl<T> Index<usize> for Vec<T> {
type Output = T;

#[inline]
fn index<'a>(&'a self, index: &usize) -> &'a T {
fn index(&self, index: &usize) -> &T {
// NB built-in indexing via `&[T]`
&(**self)[*index]
}
Expand All @@ -1289,7 +1289,7 @@ impl<T> IndexMut<usize> for Vec<T> {
type Output = T;

#[inline]
fn index_mut<'a>(&'a mut self, index: &usize) -> &'a mut T {
fn index_mut(&mut self, index: &usize) -> &mut T {
// NB built-in indexing via `&mut [T]`
&mut (**self)[*index]
}
Expand Down Expand Up @@ -1366,12 +1366,12 @@ impl<T> ops::IndexMut<ops::RangeFull> for Vec<T> {
impl<T> ops::Deref for Vec<T> {
type Target = [T];

fn deref<'a>(&'a self) -> &'a [T] { self.as_slice() }
fn deref(&self) -> &[T] { self.as_slice() }
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> ops::DerefMut for Vec<T> {
fn deref_mut<'a>(&'a mut self) -> &'a mut [T] { self.as_mut_slice() }
fn deref_mut(&mut self) -> &mut [T] { self.as_mut_slice() }
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -1519,7 +1519,7 @@ impl<T> AsSlice<T> for Vec<T> {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn as_slice<'a>(&'a self) -> &'a [T] {
fn as_slice(&self) -> &[T] {
unsafe {
mem::transmute(RawSlice {
data: *self.ptr,
Expand Down Expand Up @@ -1636,7 +1636,7 @@ impl<T> Iterator for IntoIter<T> {
type Item = T;

#[inline]
fn next<'a>(&'a mut self) -> Option<T> {
fn next(&mut self) -> Option<T> {
unsafe {
if self.ptr == self.end {
None
Expand Down Expand Up @@ -1671,7 +1671,7 @@ impl<T> Iterator for IntoIter<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> DoubleEndedIterator for IntoIter<T> {
#[inline]
fn next_back<'a>(&'a mut self) -> Option<T> {
fn next_back(&mut self) -> Option<T> {
unsafe {
if self.end == self.ptr {
None
Expand Down

0 comments on commit 1420ceb

Please sign in to comment.