Skip to content

Commit 1c6d50b

Browse files
committed
---
yaml --- r: 34190 b: refs/heads/snap-stage3 c: 85bb1fc h: refs/heads/master v: v3
1 parent 2a323df commit 1c6d50b

File tree

10 files changed

+50
-56
lines changed

10 files changed

+50
-56
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 88962eeed86631b6646fce0602acd7daae7a1ddc
4+
refs/heads/snap-stage3: 85bb1fc2c4e2060bc9b9800743c840c261e47fb3
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcore/iter-trait.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ impl<A> IMPL_T<A>: iter::ExtendedIter<A> {
4040
pure fn position(&self, f: fn(&A) -> bool) -> Option<uint> {
4141
iter::position(self, f)
4242
}
43+
pure fn map_to_vec<B>(&self, op: fn(&A) -> B) -> ~[B] {
44+
iter::map_to_vec(self, op)
45+
}
46+
pure fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: fn(&A) -> IB)
47+
-> ~[B] {
48+
iter::flat_map_to_vec(self, op)
49+
}
50+
4351
}
4452

4553
impl<A: Eq> IMPL_T<A>: iter::EqIter<A> {
@@ -48,19 +56,11 @@ impl<A: Eq> IMPL_T<A>: iter::EqIter<A> {
4856
}
4957

5058
impl<A: Copy> IMPL_T<A>: iter::CopyableIter<A> {
51-
pure fn filter_to_vec(&self, pred: fn(a: A) -> bool) -> ~[A] {
59+
pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] {
5260
iter::filter_to_vec(self, pred)
5361
}
54-
pure fn map_to_vec<B>(&self, op: fn(v: A) -> B) -> ~[B] {
55-
iter::map_to_vec(self, op)
56-
}
5762
pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) }
58-
59-
pure fn flat_map_to_vec<B:Copy,IB:BaseIter<B>>(&self, op: fn(a: A) -> IB)
60-
-> ~[B] {
61-
iter::flat_map_to_vec(self, op)
62-
}
63-
pure fn find(&self, f: fn(A) -> bool) -> Option<A> {
63+
pure fn find(&self, f: fn(&A) -> bool) -> Option<A> {
6464
iter::find(self, f)
6565
}
6666
}

branches/snap-stage3/src/libcore/iter.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ pub trait ExtendedIter<A> {
3333
pure fn any(&self, blk: fn(&A) -> bool) -> bool;
3434
pure fn foldl<B>(&self, b0: B, blk: fn(&B, &A) -> B) -> B;
3535
pure fn position(&self, f: fn(&A) -> bool) -> Option<uint>;
36+
pure fn map_to_vec<B>(&self, op: fn(&A) -> B) -> ~[B];
37+
pure fn flat_map_to_vec<B,IB: BaseIter<B>>(&self, op: fn(&A) -> IB)
38+
-> ~[B];
3639
}
3740

3841
pub trait EqIter<A:Eq> {
@@ -45,12 +48,9 @@ pub trait Times {
4548
}
4649

4750
pub trait CopyableIter<A:Copy> {
48-
pure fn filter_to_vec(&self, pred: fn(a: A) -> bool) -> ~[A];
49-
pure fn map_to_vec<B>(&self, op: fn(v: A) -> B) -> ~[B];
50-
pure fn flat_map_to_vec<B:Copy,IB: BaseIter<B>>(&self, op: fn(A) -> IB)
51-
-> ~[B];
51+
pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A];
5252
pure fn to_vec(&self) -> ~[A];
53-
pure fn find(&self, p: fn(A) -> bool) -> Option<A>;
53+
pure fn find(&self, p: fn(&A) -> bool) -> Option<A>;
5454
}
5555

5656
pub trait CopyableOrderedIter<A:Copy Ord> {
@@ -82,11 +82,11 @@ pub trait Buildable<A> {
8282
* onto the sequence being constructed.
8383
*/
8484
static pure fn build_sized(size: uint,
85-
builder: fn(push: pure fn(v: A))) -> self;
85+
builder: fn(push: pure fn(A))) -> self;
8686
}
8787

8888
pub pure fn eachi<A,IA:BaseIter<A>>(self: &IA,
89-
blk: fn(uint, v: &A) -> bool) {
89+
blk: fn(uint, &A) -> bool) {
9090
let mut i = 0;
9191
for self.each |a| {
9292
if !blk(i, a) { break; }
@@ -111,30 +111,30 @@ pub pure fn any<A,IA:BaseIter<A>>(self: &IA,
111111
}
112112

113113
pub pure fn filter_to_vec<A:Copy,IA:BaseIter<A>>(
114-
self: &IA, prd: fn(a: A) -> bool) -> ~[A] {
114+
self: &IA, prd: fn(&A) -> bool) -> ~[A] {
115115
do vec::build_sized_opt(self.size_hint()) |push| {
116116
for self.each |a| {
117-
if prd(*a) { push(*a); }
117+
if prd(a) { push(*a); }
118118
}
119119
}
120120
}
121121

122-
pub pure fn map_to_vec<A:Copy,B,IA:BaseIter<A>>(self: &IA,
123-
op: fn(v: A) -> B)
122+
pub pure fn map_to_vec<A,B,IA:BaseIter<A>>(self: &IA,
123+
op: fn(&A) -> B)
124124
-> ~[B] {
125125
do vec::build_sized_opt(self.size_hint()) |push| {
126126
for self.each |a| {
127-
push(op(*a));
127+
push(op(a));
128128
}
129129
}
130130
}
131131

132-
pub pure fn flat_map_to_vec<A:Copy,B:Copy,IA:BaseIter<A>,IB:BaseIter<B>>(
133-
self: &IA, op: fn(a: A) -> IB) -> ~[B] {
132+
pub pure fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(
133+
self: &IA, op: fn(&A) -> IB) -> ~[B] {
134134
do vec::build |push| {
135135
for self.each |a| {
136-
for op(*a).each |b| {
137-
push(*b);
136+
for op(a).each |&b| {
137+
push(b);
138138
}
139139
}
140140
}
@@ -223,9 +223,9 @@ pub pure fn max<A:Copy Ord,IA:BaseIter<A>>(self: &IA) -> A {
223223
}
224224

225225
pub pure fn find<A: Copy,IA:BaseIter<A>>(self: &IA,
226-
f: fn(A) -> bool) -> Option<A> {
226+
f: fn(&A) -> bool) -> Option<A> {
227227
for self.each |i| {
228-
if f(*i) { return Some(*i) }
228+
if f(i) { return Some(*i) }
229229
}
230230
return None;
231231
}
@@ -243,7 +243,7 @@ pub pure fn find<A: Copy,IA:BaseIter<A>>(self: &IA,
243243
* onto the sequence being constructed.
244244
*/
245245
#[inline(always)]
246-
pub pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(v: A)))
246+
pub pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(A)))
247247
-> B {
248248
Buildable::build_sized(4, builder)
249249
}
@@ -264,7 +264,7 @@ pub pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(v: A)))
264264
#[inline(always)]
265265
pub pure fn build_sized_opt<A,B: Buildable<A>>(
266266
size: Option<uint>,
267-
builder: fn(push: pure fn(v: A))) -> B {
267+
builder: fn(push: pure fn(A))) -> B {
268268

269269
Buildable::build_sized(size.get_default(4), builder)
270270
}

branches/snap-stage3/src/libcore/vec.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,6 +2040,13 @@ impl<A> &[A]: iter::ExtendedIter<A> {
20402040
pub pure fn position(&self, f: fn(&A) -> bool) -> Option<uint> {
20412041
iter::position(self, f)
20422042
}
2043+
pure fn map_to_vec<B>(&self, op: fn(&A) -> B) -> ~[B] {
2044+
iter::map_to_vec(self, op)
2045+
}
2046+
pure fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: fn(&A) -> IB)
2047+
-> ~[B] {
2048+
iter::flat_map_to_vec(self, op)
2049+
}
20432050
}
20442051

20452052
impl<A: Eq> &[A]: iter::EqIter<A> {
@@ -2048,20 +2055,11 @@ impl<A: Eq> &[A]: iter::EqIter<A> {
20482055
}
20492056

20502057
impl<A: Copy> &[A]: iter::CopyableIter<A> {
2051-
pure fn filter_to_vec(&self, pred: fn(a: A) -> bool) -> ~[A] {
2058+
pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] {
20522059
iter::filter_to_vec(self, pred)
20532060
}
2054-
pure fn map_to_vec<B>(&self, op: fn(v: A) -> B) -> ~[B] {
2055-
iter::map_to_vec(self, op)
2056-
}
20572061
pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) }
2058-
2059-
pure fn flat_map_to_vec<B:Copy,IB:BaseIter<B>>(&self, op: fn(A) -> IB)
2060-
-> ~[B] {
2061-
iter::flat_map_to_vec(self, op)
2062-
}
2063-
2064-
pub pure fn find(&self, f: fn(A) -> bool) -> Option<A> {
2062+
pub pure fn find(&self, f: fn(&A) -> bool) -> Option<A> {
20652063
iter::find(self, f)
20662064
}
20672065
}

branches/snap-stage3/src/librustc/metadata/creader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn warn_if_multiple_versions(e: env, diag: span_handler,
7070
if crate_cache.len() != 0u {
7171
let name = loader::crate_name_from_metas(*crate_cache.last().metas);
7272
let (matches, non_matches) =
73-
partition(crate_cache.map_to_vec(|entry| {
73+
partition(crate_cache.map_to_vec(|&entry| {
7474
let othername = loader::crate_name_from_metas(*entry.metas);
7575
if name == othername {
7676
Left(entry)

branches/snap-stage3/src/librustc/middle/typeck/check/method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ impl LookupContext {
861861
-> Option<method_map_entry>
862862
{
863863
let relevant_candidates =
864-
candidates.filter_to_vec(|c| self.is_relevant(self_ty, &c));
864+
candidates.filter_to_vec(|c| self.is_relevant(self_ty, c));
865865

866866
let relevant_candidates = self.merge_candidates(relevant_candidates);
867867

branches/snap-stage3/src/librustdoc/attr_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn parse_desc_should_parse_simple_doc_attributes() {
115115

116116
pub fn parse_hidden(+attrs: ~[ast::attribute]) -> bool {
117117
do doc_metas(attrs).find |meta| {
118-
match attr::get_meta_item_list(meta) {
118+
match attr::get_meta_item_list(*meta) {
119119
Some(metas) => {
120120
let hiddens = attr::find_meta_items_by_name(metas, ~"hidden");
121121
vec::is_not_empty(hiddens)

branches/snap-stage3/src/libsyntax/ext/pipes/proto.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ fn visit<Tproto, Tstate, Tmessage, V: visitor<Tproto, Tstate, Tmessage>>(
218218
proto: protocol, visitor: V) -> Tproto {
219219

220220
// the copy keywords prevent recursive use of dvec
221-
let states = do (copy proto.states).map_to_vec |s| {
222-
let messages = do (copy s.messages).map_to_vec |m| {
221+
let states = do (copy proto.states).map_to_vec |&s| {
222+
let messages = do (copy s.messages).map_to_vec |&m| {
223223
let message(name, span, tys, this, next) = m;
224224
visitor.visit_message(name, span, tys, this, next)
225225
};

branches/snap-stage3/src/test/run-pass/issue-2611.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// xfail-fast
12-
#[legacy_modes];
13-
1411
use iter::BaseIter;
1512

1613
trait FlatMapToVec<A> {
17-
fn flat_map_to_vec<B:Copy, IB:BaseIter<B>>(op: fn(+a: A) -> IB) -> ~[B];
14+
fn flat_map_to_vec<B, IB:BaseIter<B>>(op: fn(&A) -> IB) -> ~[B];
1815
}
1916

2017
impl<A:Copy> BaseIter<A>: FlatMapToVec<A> {
21-
fn flat_map_to_vec<B:Copy, IB:BaseIter<B>>(op: fn(+a: A) -> IB) -> ~[B] {
18+
fn flat_map_to_vec<B, IB:BaseIter<B>>(op: fn(&A) -> IB) -> ~[B] {
2219
iter::flat_map_to_vec(&self, op)
2320
}
2421
}

branches/snap-stage3/src/test/run-pass/iter-flat-map-to-vec.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
// except according to those terms.
1010

1111
// xfail-test -- flat_map_to_vec currently disable
12+
fn repeat(x: &uint) -> ~[uint] { ~[x, x] }
1213

13-
fn repeat(&&x: uint) -> ~[uint] { ~[x, x] }
14-
15-
fn incd_if_even(&&x: uint) -> option<uint> {
14+
fn incd_if_even(x: &uint) -> option<uint> {
1615
if (x % 2u) == 0u {some(x + 1u)} else {none}
1716
}
1817

@@ -28,4 +27,4 @@ fn main() {
2827
assert none.flat_map_to_vec(incd_if_even) == ~[];
2928
assert some(1u).flat_map_to_vec(incd_if_even) == ~[];
3029
assert some(2u).flat_map_to_vec(incd_if_even) == ~[3u];
31-
}
30+
}

0 commit comments

Comments
 (0)