Skip to content

Commit 1f7b46f

Browse files
committed
---
yaml --- r: 144191 b: refs/heads/try2 c: 0c6cc11 h: refs/heads/master i: 144189: c047a2f 144187: 5256b51 144183: cc4b446 144175: 1dcf1e0 144159: b1cd488 144127: 0cebff3 v: v3
1 parent d6db339 commit 1f7b46f

File tree

9 files changed

+337
-271
lines changed

9 files changed

+337
-271
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: 3d720c6c09aff77068caaad8668834878132c7ae
8+
refs/heads/try2: 0c6cc11e05de145641a610c342b75c2f9f01ce6d
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ extern mod complicated_mod = "some-file/in/the-rust/path";
788788
##### Use declarations
789789

790790
~~~~~~~~ {.ebnf .gram}
791-
use_decl : "pub"? "use" ident [ '=' path
791+
use_decl : "pub" ? "use" ident [ '=' path
792792
| "::" path_glob ] ;
793793
794794
path_glob : ident [ "::" path_glob ] ?
@@ -1920,7 +1920,7 @@ it is automatically dereferenced to make the field access possible.
19201920
### Vector expressions
19211921

19221922
~~~~~~~~{.ebnf .gram}
1923-
vec_expr : '[' "mut"? vec_elems? ']'
1923+
vec_expr : '[' "mut" ? vec_elems? ']'
19241924
19251925
vec_elems : [expr [',' expr]*] | [expr ',' ".." expr]
19261926
~~~~~~~~

branches/try2/src/etc/extract_grammar.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@
9393

9494
"//": "linecomment",
9595
"/*": "openblockcomment",
96-
"*/": "closeblockcomment"
96+
"*/": "closeblockcomment",
97+
"macro_rules": "macro_rules",
98+
"=>" : "eg",
99+
".." : "dotdot",
100+
"," : "comma"
97101
}
98102

99103
lines = []

branches/try2/src/libstd/iterator.rs

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ implementing the `Iterator` trait.
1818
*/
1919

2020
use cmp;
21-
use num::{Zero, One, Integer, Saturating};
21+
use num::{Zero, One, Integer, CheckedAdd, Saturating};
2222
use option::{Option, Some, None};
2323
use ops::{Add, Mul, Sub};
2424
use cmp::Ord;
@@ -838,7 +838,7 @@ impl<A, T: Iterator<A>, U: Iterator<A>> Iterator<A> for Chain<T, U> {
838838
let lower = a_lower.saturating_add(b_lower);
839839

840840
let upper = match (a_upper, b_upper) {
841-
(Some(x), Some(y)) => Some(x.saturating_add(y)),
841+
(Some(x), Some(y)) => x.checked_add(&y),
842842
_ => None
843843
};
844844

@@ -1115,22 +1115,34 @@ impl<A, T: Iterator<A>> Iterator<A> for Peekable<A, T> {
11151115
if self.peeked.is_some() { self.peeked.take() }
11161116
else { self.iter.next() }
11171117
}
1118+
1119+
#[inline]
1120+
fn size_hint(&self) -> (uint, Option<uint>) {
1121+
let (lo, hi) = self.iter.size_hint();
1122+
if self.peeked.is_some() {
1123+
let lo = lo.saturating_add(1);
1124+
let hi = match hi {
1125+
Some(x) => x.checked_add(&1),
1126+
None => None
1127+
};
1128+
(lo, hi)
1129+
} else {
1130+
(lo, hi)
1131+
}
1132+
}
11181133
}
11191134

11201135
impl<'self, A, T: Iterator<A>> Peekable<A, T> {
11211136
/// Return a reference to the next element of the iterator with out advancing it,
11221137
/// or None if the iterator is exhausted.
11231138
#[inline]
11241139
pub fn peek(&'self mut self) -> Option<&'self A> {
1140+
if self.peeked.is_none() {
1141+
self.peeked = self.iter.next();
1142+
}
11251143
match self.peeked {
11261144
Some(ref value) => Some(value),
1127-
None => {
1128-
self.peeked = self.iter.next();
1129-
match self.peeked {
1130-
Some(ref value) => Some(value),
1131-
None => None,
1132-
}
1133-
},
1145+
None => None,
11341146
}
11351147
}
11361148
}
@@ -1376,7 +1388,7 @@ impl<'self, A, T: Iterator<A>, B, U: Iterator<B>> Iterator<B> for
13761388
let (blo, bhi) = self.backiter.map_default((0, Some(0)), |it| it.size_hint());
13771389
let lo = flo.saturating_add(blo);
13781390
match (self.iter.size_hint(), fhi, bhi) {
1379-
((0, Some(0)), Some(a), Some(b)) => (lo, Some(a.saturating_add(b))),
1391+
((0, Some(0)), Some(a), Some(b)) => (lo, a.checked_add(&b)),
13801392
_ => (lo, None)
13811393
}
13821394
}
@@ -1482,6 +1494,12 @@ impl<'self, A, St> Iterator<A> for Unfoldr<'self, A, St> {
14821494
fn next(&mut self) -> Option<A> {
14831495
(self.f)(&mut self.state)
14841496
}
1497+
1498+
#[inline]
1499+
fn size_hint(&self) -> (uint, Option<uint>) {
1500+
// no possible known bounds at this point
1501+
(0, None)
1502+
}
14851503
}
14861504

14871505
/// An infinite iterator starting at `start` and advancing by `step` with each
@@ -1525,6 +1543,9 @@ impl<A: Add<A, A> + Ord + Clone> Iterator<A> for Range<A> {
15251543
None
15261544
}
15271545
}
1546+
1547+
// FIXME: #8606 Implement size_hint() on Range
1548+
// Blocked on #8605 Need numeric trait for converting to `Option<uint>`
15281549
}
15291550

15301551
impl<A: Sub<A, A> + Integer + Ord + Clone> DoubleEndedIterator<A> for Range<A> {

0 commit comments

Comments
 (0)