Skip to content

Commit 0904aaf

Browse files
committed
---
yaml --- r: 139871 b: refs/heads/try2 c: b329f2f h: refs/heads/master i: 139869: 18be82f 139867: 4c97c57 139863: 3c7c4a6 139855: f5e5230 139839: fc06cb8 v: v3
1 parent 7687a21 commit 0904aaf

20 files changed

+541
-274
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 6030e3982a52c8d9ede225f992088bb75fba4ef1
8+
refs/heads/try2: b329f2fa82185c9e7c6bbbdf26270dd839618e9c
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,4 @@ config.stamp
8686
.DS_Store
8787
src/etc/dl
8888
.settings/
89+
build/

branches/try2/src/libcore/io.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub trait ReaderUtil {
176176
fn read_bytes(&self, len: uint) -> ~[u8];
177177

178178
/**
179-
* Reads up until a specific character or EOF.
179+
* Reads up until a specific byte is seen or EOF.
180180
*
181181
* The `include` parameter specifies if the character should be included
182182
* in the returned string.
@@ -185,7 +185,7 @@ pub trait ReaderUtil {
185185
*
186186
* None right now.
187187
*/
188-
fn read_until(&self, c: char, include: bool) -> ~str;
188+
fn read_until(&self, c: u8, include: bool) -> ~str;
189189

190190
/**
191191
* Reads up until the first '\n' or EOF.
@@ -577,7 +577,7 @@ impl<T:Reader> ReaderUtil for T {
577577
bytes
578578
}
579579

580-
fn read_until(&self, c: char, include: bool) -> ~str {
580+
fn read_until(&self, c: u8, include: bool) -> ~str {
581581
let mut bytes = ~[];
582582
loop {
583583
let ch = self.read_byte();
@@ -593,7 +593,7 @@ impl<T:Reader> ReaderUtil for T {
593593
}
594594

595595
fn read_line(&self) -> ~str {
596-
self.read_until('\n', false)
596+
self.read_until('\n' as u8, false)
597597
}
598598

599599
fn read_chars(&self, n: uint) -> ~[char] {
@@ -667,7 +667,7 @@ impl<T:Reader> ReaderUtil for T {
667667
}
668668

669669
fn read_c_str(&self) -> ~str {
670-
self.read_until(0 as char, false)
670+
self.read_until(0u8, false)
671671
}
672672

673673
fn read_whole_stream(&self) -> ~[u8] {
@@ -693,7 +693,7 @@ impl<T:Reader> ReaderUtil for T {
693693
// include the \n, so that we can distinguish an entirely empty
694694
// line read after "...\n", and the trailing empty line in
695695
// "...\n\n".
696-
let mut line = self.read_until('\n', true);
696+
let mut line = self.read_until('\n' as u8, true);
697697

698698
// blank line at the end of the reader is ignored
699699
if self.eof() && line.is_empty() { break; }

branches/try2/src/libcore/iterator.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub trait IteratorUtil<A> {
2222
// FIXME: #5898: should be called map
2323
fn transform<'r, B>(self, f: &'r fn(A) -> B) -> MapIterator<'r, A, B, Self>;
2424
fn filter<'r>(self, predicate: &'r fn(&A) -> bool) -> FilterIterator<'r, A, Self>;
25+
fn enumerate(self) -> EnumerateIterator<Self>;
2526
fn advance(&mut self, f: &fn(A) -> bool);
2627
}
2728

@@ -42,6 +43,11 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
4243
FilterIterator{iter: self, predicate: predicate}
4344
}
4445

46+
#[inline(always)]
47+
fn enumerate(self) -> EnumerateIterator<T> {
48+
EnumerateIterator{iter: self, count: 0}
49+
}
50+
4551
/// A shim implementing the `for` loop iteration protocol for iterator objects
4652
#[inline]
4753
fn advance(&mut self, f: &fn(A) -> bool) {
@@ -104,3 +110,22 @@ impl<'self, A, B, T: Iterator<A>> Iterator<B> for MapIterator<'self, A, B, T> {
104110
}
105111
}
106112
}
113+
114+
pub struct EnumerateIterator<T> {
115+
priv iter: T,
116+
priv count: uint
117+
}
118+
119+
impl<A, T: Iterator<A>> Iterator<(uint, A)> for EnumerateIterator<T> {
120+
#[inline]
121+
fn next(&mut self) -> Option<(uint, A)> {
122+
match self.iter.next() {
123+
Some(a) => {
124+
let ret = Some((self.count, a));
125+
self.count += 1;
126+
ret
127+
}
128+
_ => None
129+
}
130+
}
131+
}

branches/try2/src/libcore/num/f32.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,26 +288,32 @@ impl num::One for f32 {
288288

289289
#[cfg(notest)]
290290
impl ops::Add<f32,f32> for f32 {
291+
#[inline(always)]
291292
fn add(&self, other: &f32) -> f32 { *self + *other }
292293
}
293294
#[cfg(notest)]
294295
impl ops::Sub<f32,f32> for f32 {
296+
#[inline(always)]
295297
fn sub(&self, other: &f32) -> f32 { *self - *other }
296298
}
297299
#[cfg(notest)]
298300
impl ops::Mul<f32,f32> for f32 {
301+
#[inline(always)]
299302
fn mul(&self, other: &f32) -> f32 { *self * *other }
300303
}
301304
#[cfg(notest)]
302305
impl ops::Div<f32,f32> for f32 {
306+
#[inline(always)]
303307
fn div(&self, other: &f32) -> f32 { *self / *other }
304308
}
305309
#[cfg(notest)]
306310
impl ops::Modulo<f32,f32> for f32 {
311+
#[inline(always)]
307312
fn modulo(&self, other: &f32) -> f32 { *self % *other }
308313
}
309314
#[cfg(notest)]
310315
impl ops::Neg<f32> for f32 {
316+
#[inline(always)]
311317
fn neg(&self) -> f32 { -*self }
312318
}
313319

branches/try2/src/libcore/num/f64.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,26 +310,32 @@ impl num::One for f64 {
310310

311311
#[cfg(notest)]
312312
impl ops::Add<f64,f64> for f64 {
313+
#[inline(always)]
313314
fn add(&self, other: &f64) -> f64 { *self + *other }
314315
}
315316
#[cfg(notest)]
316317
impl ops::Sub<f64,f64> for f64 {
318+
#[inline(always)]
317319
fn sub(&self, other: &f64) -> f64 { *self - *other }
318320
}
319321
#[cfg(notest)]
320322
impl ops::Mul<f64,f64> for f64 {
323+
#[inline(always)]
321324
fn mul(&self, other: &f64) -> f64 { *self * *other }
322325
}
323326
#[cfg(notest)]
324327
impl ops::Div<f64,f64> for f64 {
328+
#[inline(always)]
325329
fn div(&self, other: &f64) -> f64 { *self / *other }
326330
}
327331
#[cfg(notest)]
328332
impl ops::Modulo<f64,f64> for f64 {
333+
#[inline(always)]
329334
fn modulo(&self, other: &f64) -> f64 { *self % *other }
330335
}
331336
#[cfg(notest)]
332337
impl ops::Neg<f64> for f64 {
338+
#[inline(always)]
333339
fn neg(&self) -> f64 { -*self }
334340
}
335341

0 commit comments

Comments
 (0)