Skip to content

Commit 63fd687

Browse files
committed
allow some deprecated
1 parent efd2591 commit 63fd687

File tree

8 files changed

+76
-52
lines changed

8 files changed

+76
-52
lines changed

src/libcollections/bit.rs

Lines changed: 61 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ use core::fmt;
8888
use core::iter::{Cloned, Chain, Enumerate, Repeat, Skip, Take};
8989
use core::iter;
9090
use core::num::Int;
91-
use core::slice::{Iter, IterMut};
91+
use core::slice;
9292
use core::{u8, u32, uint};
9393

9494
use core::hash;
9595
use Vec;
9696

97-
type Blocks<'a> = Cloned<Iter<'a, u32>>;
98-
type MutBlocks<'a> = IterMut<'a, u32>;
97+
type Blocks<'a> = Cloned<slice::Iter<'a, u32>>;
98+
type MutBlocks<'a> = slice::IterMut<'a, u32>;
9999
type MatchWords<'a> = Chain<Enumerate<Blocks<'a>>, Skip<Take<Enumerate<Repeat<u32>>>>>;
100100

101101
fn reverse_bits(byte: u8) -> u8 {
@@ -163,7 +163,7 @@ pub struct Bitv {
163163
// FIXME(Gankro): NopeNopeNopeNopeNope (wait for IndexGet to be a thing)
164164
impl Index<uint,bool> for Bitv {
165165
#[inline]
166-
fn index<'a>(&'a self, i: &uint) -> &'a bool {
166+
fn index(&self, i: &uint) -> &bool {
167167
if self.get(*i).expect("index out of bounds") {
168168
&TRUE
169169
} else {
@@ -580,8 +580,8 @@ impl Bitv {
580580
/// ```
581581
#[inline]
582582
#[stable]
583-
pub fn iter<'a>(&'a self) -> Bits<'a> {
584-
Bits { bitv: self, next_idx: 0, end_idx: self.nbits }
583+
pub fn iter(&self) -> Iter {
584+
Iter { bitv: self, next_idx: 0, end_idx: self.nbits }
585585
}
586586

587587
/// Returns `true` if all bits are 0.
@@ -1018,15 +1018,15 @@ impl cmp::PartialEq for Bitv {
10181018
impl cmp::Eq for Bitv {}
10191019

10201020
/// An iterator for `Bitv`.
1021-
#[unstable = "needs to be newtyped"]
1022-
pub struct Bits<'a> {
1021+
#[stable]
1022+
pub struct Iter<'a> {
10231023
bitv: &'a Bitv,
10241024
next_idx: uint,
10251025
end_idx: uint,
10261026
}
10271027

10281028
#[stable]
1029-
impl<'a> Iterator<bool> for Bits<'a> {
1029+
impl<'a> Iterator<bool> for Iter<'a> {
10301030
#[inline]
10311031
fn next(&mut self) -> Option<bool> {
10321032
if self.next_idx != self.end_idx {
@@ -1045,7 +1045,7 @@ impl<'a> Iterator<bool> for Bits<'a> {
10451045
}
10461046

10471047
#[stable]
1048-
impl<'a> DoubleEndedIterator<bool> for Bits<'a> {
1048+
impl<'a> DoubleEndedIterator<bool> for Iter<'a> {
10491049
#[inline]
10501050
fn next_back(&mut self) -> Option<bool> {
10511051
if self.next_idx != self.end_idx {
@@ -1058,10 +1058,10 @@ impl<'a> DoubleEndedIterator<bool> for Bits<'a> {
10581058
}
10591059

10601060
#[stable]
1061-
impl<'a> ExactSizeIterator<bool> for Bits<'a> {}
1061+
impl<'a> ExactSizeIterator<bool> for Iter<'a> {}
10621062

10631063
#[stable]
1064-
impl<'a> RandomAccessIterator<bool> for Bits<'a> {
1064+
impl<'a> RandomAccessIterator<bool> for Iter<'a> {
10651065
#[inline]
10661066
fn indexable(&self) -> uint {
10671067
self.end_idx - self.next_idx
@@ -1332,7 +1332,7 @@ impl BitvSet {
13321332
/// assert_eq!(bv[0], true);
13331333
/// ```
13341334
#[inline]
1335-
pub fn get_ref<'a>(&'a self) -> &'a Bitv {
1335+
pub fn get_ref(&self) -> &Bitv {
13361336
&self.bitv
13371337
}
13381338

@@ -1412,8 +1412,8 @@ impl BitvSet {
14121412
/// ```
14131413
#[inline]
14141414
#[stable]
1415-
pub fn iter<'a>(&'a self) -> BitPositions<'a> {
1416-
BitPositions {set: self, next_idx: 0u}
1415+
pub fn iter(&self) -> SetIter {
1416+
SetIter {set: self, next_idx: 0u}
14171417
}
14181418

14191419
/// Iterator over each u32 stored in `self` union `other`.
@@ -1434,16 +1434,16 @@ impl BitvSet {
14341434
/// ```
14351435
#[inline]
14361436
#[stable]
1437-
pub fn union<'a>(&'a self, other: &'a BitvSet) -> TwoBitPositions<'a> {
1437+
pub fn union<'a>(&'a self, other: &'a BitvSet) -> Union<'a> {
14381438
fn or(w1: u32, w2: u32) -> u32 { w1 | w2 }
14391439

1440-
TwoBitPositions {
1440+
Union(TwoBitPositions {
14411441
set: self,
14421442
other: other,
14431443
merge: or,
14441444
current_word: 0u32,
14451445
next_idx: 0u
1446-
}
1446+
})
14471447
}
14481448

14491449
/// Iterator over each uint stored in `self` intersect `other`.
@@ -1464,16 +1464,16 @@ impl BitvSet {
14641464
/// ```
14651465
#[inline]
14661466
#[stable]
1467-
pub fn intersection<'a>(&'a self, other: &'a BitvSet) -> Take<TwoBitPositions<'a>> {
1467+
pub fn intersection<'a>(&'a self, other: &'a BitvSet) -> Intersection<'a> {
14681468
fn bitand(w1: u32, w2: u32) -> u32 { w1 & w2 }
14691469
let min = cmp::min(self.bitv.len(), other.bitv.len());
1470-
TwoBitPositions {
1470+
Intersection(TwoBitPositions {
14711471
set: self,
14721472
other: other,
14731473
merge: bitand,
14741474
current_word: 0u32,
14751475
next_idx: 0
1476-
}.take(min)
1476+
}.take(min))
14771477
}
14781478

14791479
/// Iterator over each uint stored in the `self` setminus `other`.
@@ -1501,16 +1501,16 @@ impl BitvSet {
15011501
/// ```
15021502
#[inline]
15031503
#[stable]
1504-
pub fn difference<'a>(&'a self, other: &'a BitvSet) -> TwoBitPositions<'a> {
1504+
pub fn difference<'a>(&'a self, other: &'a BitvSet) -> Difference<'a> {
15051505
fn diff(w1: u32, w2: u32) -> u32 { w1 & !w2 }
15061506

1507-
TwoBitPositions {
1507+
Difference(TwoBitPositions {
15081508
set: self,
15091509
other: other,
15101510
merge: diff,
15111511
current_word: 0u32,
15121512
next_idx: 0
1513-
}
1513+
})
15141514
}
15151515

15161516
/// Iterator over each u32 stored in the symmetric difference of `self` and `other`.
@@ -1532,16 +1532,16 @@ impl BitvSet {
15321532
/// ```
15331533
#[inline]
15341534
#[stable]
1535-
pub fn symmetric_difference<'a>(&'a self, other: &'a BitvSet) -> TwoBitPositions<'a> {
1535+
pub fn symmetric_difference<'a>(&'a self, other: &'a BitvSet) -> SymmetricDifference<'a> {
15361536
fn bitxor(w1: u32, w2: u32) -> u32 { w1 ^ w2 }
15371537

1538-
TwoBitPositions {
1538+
SymmetricDifference(TwoBitPositions {
15391539
set: self,
15401540
other: other,
15411541
merge: bitxor,
15421542
current_word: 0u32,
15431543
next_idx: 0
1544-
}
1544+
})
15451545
}
15461546

15471547
/// Unions in-place with the specified other bit vector.
@@ -1760,15 +1760,14 @@ impl<S: hash::Writer> hash::Hash<S> for BitvSet {
17601760
}
17611761

17621762
/// An iterator for `BitvSet`.
1763-
#[unstable = "needs to be newtyped"]
1764-
pub struct BitPositions<'a> {
1763+
#[stable]
1764+
pub struct SetIter<'a> {
17651765
set: &'a BitvSet,
17661766
next_idx: uint
17671767
}
17681768

17691769
/// An iterator combining two `BitvSet` iterators.
1770-
#[unstable = "needs to be newtyped"]
1771-
pub struct TwoBitPositions<'a> {
1770+
struct TwoBitPositions<'a> {
17721771
set: &'a BitvSet,
17731772
other: &'a BitvSet,
17741773
merge: fn(u32, u32) -> u32,
@@ -1777,7 +1776,16 @@ pub struct TwoBitPositions<'a> {
17771776
}
17781777

17791778
#[stable]
1780-
impl<'a> Iterator<uint> for BitPositions<'a> {
1779+
pub struct Union<'a>(TwoBitPositions<'a>);
1780+
#[stable]
1781+
pub struct Intersection<'a>(Take<TwoBitPositions<'a>>);
1782+
#[stable]
1783+
pub struct Difference<'a>(TwoBitPositions<'a>);
1784+
#[stable]
1785+
pub struct SymmetricDifference<'a>(TwoBitPositions<'a>);
1786+
1787+
#[stable]
1788+
impl<'a> Iterator<uint> for SetIter<'a> {
17811789
fn next(&mut self) -> Option<uint> {
17821790
while self.next_idx < self.set.bitv.len() {
17831791
let idx = self.next_idx;
@@ -1833,8 +1841,29 @@ impl<'a> Iterator<uint> for TwoBitPositions<'a> {
18331841
}
18341842
}
18351843

1844+
#[stable]
1845+
impl<'a> Iterator<uint> for Union<'a> {
1846+
#[inline] fn next(&mut self) -> Option<uint> { self.0.next() }
1847+
#[inline] fn size_hint(&self) -> (uint, Option<uint>) { self.0.size_hint() }
1848+
}
18361849

1850+
#[stable]
1851+
impl<'a> Iterator<uint> for Intersection<'a> {
1852+
#[inline] fn next(&mut self) -> Option<uint> { self.0.next() }
1853+
#[inline] fn size_hint(&self) -> (uint, Option<uint>) { self.0.size_hint() }
1854+
}
18371855

1856+
#[stable]
1857+
impl<'a> Iterator<uint> for Difference<'a> {
1858+
#[inline] fn next(&mut self) -> Option<uint> { self.0.next() }
1859+
#[inline] fn size_hint(&self) -> (uint, Option<uint>) { self.0.size_hint() }
1860+
}
1861+
1862+
#[stable]
1863+
impl<'a> Iterator<uint> for SymmetricDifference<'a> {
1864+
#[inline] fn next(&mut self) -> Option<uint> { self.0.next() }
1865+
#[inline] fn size_hint(&self) -> (uint, Option<uint>) { self.0.size_hint() }
1866+
}
18381867

18391868

18401869
#[cfg(test)]

src/libcollections/btree/map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ impl<K, V> BTreeMap<K, V> {
11671167
/// assert_eq!((*first_key, *first_value), (1u, "a"));
11681168
/// ```
11691169
#[stable]
1170-
pub fn iter<'a>(&'a self) -> Iter<'a, K, V> {
1170+
pub fn iter(&self) -> Iter<K, V> {
11711171
let len = self.len();
11721172
Iter {
11731173
inner: AbsIter {
@@ -1199,7 +1199,7 @@ impl<K, V> BTreeMap<K, V> {
11991199
/// }
12001200
/// ```
12011201
#[stable]
1202-
pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, K, V> {
1202+
pub fn iter_mut(&mut self) -> IterMut<K, V> {
12031203
let len = self.len();
12041204
IterMut {
12051205
inner: AbsIter {

src/libcollections/btree/set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl<T> BTreeSet<T> {
115115
/// assert_eq!(v, vec![1u,2,3,4]);
116116
/// ```
117117
#[stable]
118-
pub fn iter<'a>(&'a self) -> Iter<'a, T> {
118+
pub fn iter(&self) -> Iter<T> {
119119
Iter { iter: self.map.keys() }
120120
}
121121

src/libcollections/dlist.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,13 @@ struct Node<T> {
5555

5656
/// An iterator over references to the items of a `DList`.
5757
#[stable]
58+
#[deriving(Clone)]
5859
pub struct Iter<'a, T:'a> {
5960
head: &'a Link<T>,
6061
tail: Rawlink<Node<T>>,
6162
nelem: uint,
6263
}
6364

64-
// FIXME #11820: the &'a Option<> of the Link stops clone working.
65-
#[stable]
66-
impl<'a, T> Clone for Iter<'a, T> {
67-
fn clone(&self) -> Iter<'a, T> { *self }
68-
}
69-
70-
#[unstable = "copyable iterators are dubious"]
71-
impl<'a,T> Copy for Iter<'a,T> {}
72-
7365
/// An iterator over mutable references to the items of a `DList`.
7466
#[stable]
7567
pub struct IterMut<'a, T:'a> {
@@ -319,14 +311,14 @@ impl<T> DList<T> {
319311
/// Provides a forward iterator.
320312
#[inline]
321313
#[stable]
322-
pub fn iter<'a>(&'a self) -> Iter<'a, T> {
314+
pub fn iter(&self) -> Iter<T> {
323315
Iter{nelem: self.len(), head: &self.list_head, tail: self.list_tail}
324316
}
325317

326318
/// Provides a forward iterator with mutable references.
327319
#[inline]
328320
#[stable]
329-
pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> {
321+
pub fn iter_mut(&mut self) -> IterMut<T> {
330322
let head_raw = match self.list_head {
331323
Some(ref mut h) => Rawlink::some(&mut **h),
332324
None => Rawlink::none(),
@@ -474,6 +466,7 @@ impl<T> DList<T> {
474466
impl<T: Ord> DList<T> {
475467
/// Deprecated: Why are you maintaining a sorted DList?
476468
#[deprecated = "Why are you maintaining a sorted DList?"]
469+
#[allow(deprecated)]
477470
pub fn insert_ordered(&mut self, elt: T) {
478471
self.insert_when(elt, |a, b| a >= b)
479472
}

src/libcollections/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ pub mod vec;
6464
pub mod vec_map;
6565

6666
pub mod bitv {
67-
pub use bit::{Bitv, Bits, from_fn, from_bytes};
67+
pub use bit::{Bitv, Iter, from_fn, from_bytes};
6868
}
6969

7070
pub mod bitv_set {
71-
pub use bit::{BitvSet, BitPositions, TwoBitPositions};
71+
pub use bit::{BitvSet, Union, Intersection, Difference, SymmetricDifference};
72+
pub use bit::SetIter as Iter;
7273
}
7374

7475
pub mod btree_map {

src/libcollections/ring_buf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ impl<T> Default for RingBuf<T> {
8080
impl<T> RingBuf<T> {
8181
/// Turn ptr into a slice
8282
#[inline]
83-
unsafe fn buffer_as_slice<'a>(&'a self) -> &'a [T] {
83+
unsafe fn buffer_as_slice(&self) -> &[T] {
8484
mem::transmute(RawSlice { data: self.ptr as *const T, len: self.cap })
8585
}
8686

8787
/// Turn ptr into a mut slice
8888
#[inline]
89-
unsafe fn buffer_as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
89+
unsafe fn buffer_as_mut_slice(&mut self) -> &mut [T] {
9090
mem::transmute(RawSlice { data: self.ptr as *const T, len: self.cap })
9191
}
9292

@@ -509,7 +509,7 @@ impl<T> RingBuf<T> {
509509
/// ```
510510
#[inline]
511511
#[unstable = "matches collection reform specification, waiting for dust to settle"]
512-
pub fn drain<'a>(&'a mut self) -> Drain<'a, T> {
512+
pub fn drain(&mut self) -> Drain<T> {
513513
Drain {
514514
inner: self,
515515
}

src/libcollections/vec_map.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ impl<V> VecMap<V> {
484484
impl<V:Clone> VecMap<V> {
485485
/// Deprecated: Use the entry API when available; shouldn't matter anyway, access is cheap.
486486
#[deprecated = "Use the entry API when available; shouldn't matter anyway, access is cheap"]
487+
#[allow(deprecated)]
487488
pub fn update<F>(&mut self, key: uint, newval: V, ff: F) -> bool where F: FnOnce(V, V) -> V {
488489
self.update_with_key(key, newval, move |_k, v, v1| ff(v,v1))
489490
}

src/libstd/collections/hash/set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
252252
/// }
253253
/// ```
254254
#[stable]
255-
pub fn iter<'a>(&'a self) -> Iter<'a, T> {
255+
pub fn iter(&self) -> Iter<T> {
256256
Iter { iter: self.map.keys() }
257257
}
258258

0 commit comments

Comments
 (0)