Skip to content

Commit 1420ceb

Browse files
committed
remove unecessary lifetimes from a bunch of collections code
1 parent e250fe3 commit 1420ceb

File tree

6 files changed

+50
-50
lines changed

6 files changed

+50
-50
lines changed

src/libcollections/binary_heap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ mod tests {
708708
let iterout = vec![3, 5, 9];
709709
let pq = BinaryHeap::from_vec(data);
710710

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

src/libcollections/ring_buf.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,13 +529,13 @@ impl<T> RingBuf<T> {
529529
/// assert_eq!(&buf.iter_mut().collect::<Vec<&mut i32>>()[], b);
530530
/// ```
531531
#[stable(feature = "rust1", since = "1.0.0")]
532-
pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> {
532+
pub fn iter_mut(&mut self) -> IterMut<T> {
533533
IterMut {
534534
tail: self.tail,
535535
head: self.head,
536536
cap: self.cap,
537537
ptr: self.ptr,
538-
marker: marker::ContravariantLifetime::<'a>,
538+
marker: marker::ContravariantLifetime,
539539
}
540540
}
541541

@@ -552,7 +552,7 @@ impl<T> RingBuf<T> {
552552
#[inline]
553553
#[unstable(feature = "collections",
554554
reason = "matches collection reform specification, waiting for dust to settle")]
555-
pub fn as_slices<'a>(&'a self) -> (&'a [T], &'a [T]) {
555+
pub fn as_slices(&self) -> (&[T], &[T]) {
556556
unsafe {
557557
let contiguous = self.is_contiguous();
558558
let buf = self.buffer_as_slice();
@@ -572,7 +572,7 @@ impl<T> RingBuf<T> {
572572
#[inline]
573573
#[unstable(feature = "collections",
574574
reason = "matches collection reform specification, waiting for dust to settle")]
575-
pub fn as_mut_slices<'a>(&'a mut self) -> (&'a mut [T], &'a mut [T]) {
575+
pub fn as_mut_slices(&mut self) -> (&mut [T], &mut [T]) {
576576
unsafe {
577577
let contiguous = self.is_contiguous();
578578
let head = self.head;
@@ -1584,7 +1584,7 @@ impl<A> Index<usize> for RingBuf<A> {
15841584
type Output = A;
15851585

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

15961596
#[inline]
1597-
fn index_mut<'a>(&'a mut self, i: &usize) -> &'a mut A {
1597+
fn index_mut(&mut self, i: &usize) -> &mut A {
15981598
self.get_mut(*i).expect("Out of bounds access")
15991599
}
16001600
}

src/libcollections/slice.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -812,27 +812,27 @@ impl<T> SliceExt for [T] {
812812
}
813813

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

819819
#[inline]
820-
fn slice_from<'a>(&'a self, start: usize) -> &'a [T] {
820+
fn slice_from(&self, start: usize) -> &[T] {
821821
&self[start ..]
822822
}
823823

824824
#[inline]
825-
fn slice_to<'a>(&'a self, end: usize) -> &'a [T] {
825+
fn slice_to(&self, end: usize) -> &[T] {
826826
&self[.. end]
827827
}
828828

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

834834
#[inline]
835-
fn iter<'a>(&'a self) -> Iter<'a, T> {
835+
fn iter(&self) -> Iter<T> {
836836
core_slice::SliceExt::iter(self)
837837
}
838838

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

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

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

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

872872
#[inline]
873-
fn first<'a>(&'a self) -> Option<&'a T> {
873+
fn first(&self) -> Option<&T> {
874874
core_slice::SliceExt::first(self)
875875
}
876876

877877
#[inline]
878-
fn tail<'a>(&'a self) -> &'a [T] {
878+
fn tail(&self) -> &[T] {
879879
core_slice::SliceExt::tail(self)
880880
}
881881

882882
#[inline]
883-
fn init<'a>(&'a self) -> &'a [T] {
883+
fn init(&self) -> &[T] {
884884
core_slice::SliceExt::init(self)
885885
}
886886

887887
#[inline]
888-
fn last<'a>(&'a self) -> Option<&'a T> {
888+
fn last(&self) -> Option<&T> {
889889
core_slice::SliceExt::last(self)
890890
}
891891

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

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

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

923923
#[inline]
924-
fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
924+
fn as_mut_slice(&mut self) -> &mut [T] {
925925
core_slice::SliceExt::as_mut_slice(self)
926926
}
927927

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

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

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

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

948948
#[inline]
949-
fn first_mut<'a>(&'a mut self) -> Option<&'a mut T> {
949+
fn first_mut(&mut self) -> Option<&mut T> {
950950
core_slice::SliceExt::first_mut(self)
951951
}
952952

953953
#[inline]
954-
fn tail_mut<'a>(&'a mut self) -> &'a mut [T] {
954+
fn tail_mut(&mut self) -> &mut [T] {
955955
core_slice::SliceExt::tail_mut(self)
956956
}
957957

958958
#[inline]
959-
fn init_mut<'a>(&'a mut self) -> &'a mut [T] {
959+
fn init_mut(&mut self) -> &mut [T] {
960960
core_slice::SliceExt::init_mut(self)
961961
}
962962

963963
#[inline]
964-
fn last_mut<'a>(&'a mut self) -> Option<&'a mut T> {
964+
fn last_mut(&mut self) -> Option<&mut T> {
965965
core_slice::SliceExt::last_mut(self)
966966
}
967967

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

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

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

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

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

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

src/libcollections/str.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
464464
#[inline]
465465
#[unstable(feature = "collections",
466466
reason = "this functionality may be moved to libunicode")]
467-
fn nfd_chars<'a>(&'a self) -> Decompositions<'a> {
467+
fn nfd_chars(&self) -> Decompositions {
468468
Decompositions {
469469
iter: self[].chars(),
470470
buffer: Vec::new(),
@@ -478,7 +478,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
478478
#[inline]
479479
#[unstable(feature = "collections",
480480
reason = "this functionality may be moved to libunicode")]
481-
fn nfkd_chars<'a>(&'a self) -> Decompositions<'a> {
481+
fn nfkd_chars(&self) -> Decompositions {
482482
Decompositions {
483483
iter: self[].chars(),
484484
buffer: Vec::new(),
@@ -492,7 +492,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
492492
#[inline]
493493
#[unstable(feature = "collections",
494494
reason = "this functionality may be moved to libunicode")]
495-
fn nfc_chars<'a>(&'a self) -> Recompositions<'a> {
495+
fn nfc_chars(&self) -> Recompositions {
496496
Recompositions {
497497
iter: self.nfd_chars(),
498498
state: Composing,
@@ -507,7 +507,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
507507
#[inline]
508508
#[unstable(feature = "collections",
509509
reason = "this functionality may be moved to libunicode")]
510-
fn nfkc_chars<'a>(&'a self) -> Recompositions<'a> {
510+
fn nfkc_chars(&self) -> Recompositions {
511511
Recompositions {
512512
iter: self.nfkd_chars(),
513513
state: Composing,

src/libcollections/string.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ impl String {
488488
/// ```
489489
#[inline]
490490
#[stable(feature = "rust1", since = "1.0.0")]
491-
pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
491+
pub fn as_bytes(&self) -> &[u8] {
492492
&self.vec
493493
}
494494

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

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

893893
#[inline]
894-
fn deref<'a>(&'a self) -> &'a str {
894+
fn deref(&self) -> &str {
895895
unsafe { mem::transmute(&self.vec[]) }
896896
}
897897
}

src/libcollections/vec.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ impl<T> Vec<T> {
425425
/// ```
426426
#[inline]
427427
#[stable(feature = "rust1", since = "1.0.0")]
428-
pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
428+
pub fn as_mut_slice(&mut self) -> &mut [T] {
429429
unsafe {
430430
mem::transmute(RawSlice {
431431
data: *self.ptr,
@@ -737,7 +737,7 @@ impl<T> Vec<T> {
737737
#[inline]
738738
#[unstable(feature = "collections",
739739
reason = "matches collection reform specification, waiting for dust to settle")]
740-
pub fn drain<'a>(&'a mut self) -> Drain<'a, T> {
740+
pub fn drain(&mut self) -> Drain<T> {
741741
unsafe {
742742
let begin = *self.ptr as *const T;
743743
let end = if mem::size_of::<T>() == 0 {
@@ -1278,7 +1278,7 @@ impl<T> Index<usize> for Vec<T> {
12781278
type Output = T;
12791279

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

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

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

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

13771377
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1519,7 +1519,7 @@ impl<T> AsSlice<T> for Vec<T> {
15191519
/// ```
15201520
#[inline]
15211521
#[stable(feature = "rust1", since = "1.0.0")]
1522-
fn as_slice<'a>(&'a self) -> &'a [T] {
1522+
fn as_slice(&self) -> &[T] {
15231523
unsafe {
15241524
mem::transmute(RawSlice {
15251525
data: *self.ptr,
@@ -1636,7 +1636,7 @@ impl<T> Iterator for IntoIter<T> {
16361636
type Item = T;
16371637

16381638
#[inline]
1639-
fn next<'a>(&'a mut self) -> Option<T> {
1639+
fn next(&mut self) -> Option<T> {
16401640
unsafe {
16411641
if self.ptr == self.end {
16421642
None
@@ -1671,7 +1671,7 @@ impl<T> Iterator for IntoIter<T> {
16711671
#[stable(feature = "rust1", since = "1.0.0")]
16721672
impl<T> DoubleEndedIterator for IntoIter<T> {
16731673
#[inline]
1674-
fn next_back<'a>(&'a mut self) -> Option<T> {
1674+
fn next_back(&mut self) -> Option<T> {
16751675
unsafe {
16761676
if self.end == self.ptr {
16771677
None

0 commit comments

Comments
 (0)