Skip to content

Commit eb5bddc

Browse files
committed
---
yaml --- r: 126735 b: refs/heads/snap-stage3 c: b10dcbe h: refs/heads/master i: 126733: f21bee8 126731: 5716b94 126727: 81842c4 126719: 11a914f v: v3
1 parent 700b036 commit eb5bddc

File tree

4 files changed

+22
-31
lines changed

4 files changed

+22
-31
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: 7be8f0af0393dcdb077c2f6b1653836fd3fba235
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 3e62ad3fb95b96c224e64bd83c98bc94bad5ec65
4+
refs/heads/snap-stage3: b10dcbe53ae68ba97314b5c68eddbb4ea403d59f
55
refs/heads/try: 502e4c045236682e9728539dc0d2b3d0b237f55c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/doc/guide.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -624,15 +624,10 @@ let x = (let y = 5i); // found `let` in ident position
624624
The compiler is telling us here that it was expecting to see the beginning of
625625
an expression, and a `let` can only begin a statement, not an expression.
626626

627-
However, assigning to a variable binding is an expression:
628-
629-
```{rust}
630-
let x;
631-
let y = x = 5i;
632-
```
633-
634-
In this case, we have an assignment expression (`x = 5`) whose value is
635-
being used as part of a `let` declaration statement (`let y = ...`).
627+
Note that assigning to an already-bound variable (e.g. `y = 5i`) is still an
628+
expression, although its value is not particularly useful. Unlike C, where an
629+
assignment evaluates to the assigned value (e.g. `5i` in the previous example),
630+
in Rust the value of an assignment is the unit type `()` (which we'll cover later).
636631

637632
The second kind of statement in Rust is the **expression statement**. Its
638633
purpose is to turn any expression into a statement. In practical terms, Rust's

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ pub trait Iterator<A> {
9999
/// Advance the iterator and return the next value. Return `None` when the end is reached.
100100
fn next(&mut self) -> Option<A>;
101101

102-
/// Return a lower bound and upper bound on the remaining length of the iterator.
102+
/// Returns a lower and upper bound on the remaining length of the iterator.
103103
///
104-
/// The common use case for the estimate is pre-allocating space to store the results.
104+
/// An upper bound of `None` means either there is no known upper bound, or the upper bound
105+
/// does not fit within a `uint`.
105106
#[inline]
106107
fn size_hint(&self) -> (uint, Option<uint>) { (0, None) }
107108

@@ -644,6 +645,9 @@ pub trait Iterator<A> {
644645
}
645646

646647
/// A range iterator able to yield elements from both ends
648+
///
649+
/// A `DoubleEndedIterator` can be thought of as a deque in that `next()` and `next_back()` exhaust
650+
/// elements from the *same* range, and do not work independently of each other.
647651
pub trait DoubleEndedIterator<A>: Iterator<A> {
648652
/// Yield an element from the end of the range, returning `None` if the range is empty.
649653
fn next_back(&mut self) -> Option<A>;
@@ -690,12 +694,15 @@ impl<'a, A, T: DoubleEndedIterator<&'a mut A>> MutableDoubleEndedIterator for T
690694
/// An object implementing random access indexing by `uint`
691695
///
692696
/// A `RandomAccessIterator` should be either infinite or a `DoubleEndedIterator`.
697+
/// Calling `next()` or `next_back()` on a `RandomAccessIterator`
698+
/// reduces the indexable range accordingly. That is, `it.idx(1)` will become `it.idx(0)`
699+
/// after `it.next()` is called.
693700
pub trait RandomAccessIterator<A>: Iterator<A> {
694701
/// Return the number of indexable elements. At most `std::uint::MAX`
695702
/// elements are indexable, even if the iterator represents a longer range.
696703
fn indexable(&self) -> uint;
697704

698-
/// Return an element at an index
705+
/// Return an element at an index, or `None` if the index is out of bounds
699706
fn idx(&mut self, index: uint) -> Option<A>;
700707
}
701708

branches/snap-stage3/src/libcore/num/mod.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pub trait Zero: Add<Self, Self> {
7575
fn zero() -> Self;
7676

7777
/// Returns `true` if `self` is equal to the additive identity.
78+
#[inline]
7879
fn is_zero(&self) -> bool;
7980
}
8081

@@ -89,32 +90,20 @@ macro_rules! zero_impl(
8990
}
9091
)
9192

92-
macro_rules! zero_float_impl(
93-
($t:ty, $v:expr) => {
94-
impl Zero for $t {
95-
#[inline]
96-
fn zero() -> $t { $v }
97-
98-
#[inline]
99-
fn is_zero(&self) -> bool { *self == $v || *self == -$v }
100-
}
101-
}
102-
)
103-
10493
zero_impl!(uint, 0u)
105-
zero_impl!(u8, 0u8)
106-
zero_impl!(u16, 0u16)
107-
zero_impl!(u32, 0u32)
108-
zero_impl!(u64, 0u64)
94+
zero_impl!(u8, 0u8)
95+
zero_impl!(u16, 0u16)
96+
zero_impl!(u32, 0u32)
97+
zero_impl!(u64, 0u64)
10998

11099
zero_impl!(int, 0i)
111100
zero_impl!(i8, 0i8)
112101
zero_impl!(i16, 0i16)
113102
zero_impl!(i32, 0i32)
114103
zero_impl!(i64, 0i64)
115104

116-
zero_float_impl!(f32, 0.0f32)
117-
zero_float_impl!(f64, 0.0f64)
105+
zero_impl!(f32, 0.0f32)
106+
zero_impl!(f64, 0.0f64)
118107

119108
/// Returns the additive identity, `0`.
120109
#[inline(always)] pub fn zero<T: Zero>() -> T { Zero::zero() }

0 commit comments

Comments
 (0)