Skip to content

Commit 4452e73

Browse files
steveklabnikManishearth
authored andcommitted
---
yaml --- r: 191447 b: refs/heads/try c: 351721c h: refs/heads/master i: 191445: 4007e25 191443: 68e2710 191439: 7157070 v: v3
1 parent 1a5da55 commit 4452e73

File tree

21 files changed

+94
-437
lines changed

21 files changed

+94
-437
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 809a554fca2d0ebc2ba50077016fe282a4064752
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: c64d671671aea2e44ee7fc6eb00ee75fc30ed7b9
5-
refs/heads/try: 30718dd44be229a5c61648a4aed6711441ef7b6d
5+
refs/heads/try: 351721cde6534d0a20bda8cbacc0019fca6caf3f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/doc/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2068,7 +2068,7 @@ type int8_t = i8;
20682068
item](#language-items) for more details.
20692069
- `test` - indicates that this function is a test function, to only be compiled
20702070
in case of `--test`.
2071-
- `should_panic` - indicates that this test function should panic, inverting the success condition.
2071+
- `should_fail` - indicates that this test function should panic, inverting the success condition.
20722072
- `cold` - The function is unlikely to be executed, so optimize it (and calls
20732073
to it) differently.
20742074

branches/try/src/doc/trpl/functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ Because this function will cause a crash, it will never return, and so it has
179179
the type '`!`', which is read "diverges." A diverging function can be used
180180
as any type:
181181

182-
```should_panic
182+
```should_fail
183183
# fn diverges() -> ! {
184184
# panic!("This function never returns!");
185185
# }

branches/try/src/doc/trpl/testing.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ $ echo $?
129129

130130
This is useful if you want to integrate `cargo test` into other tooling.
131131

132-
We can invert our test's failure with another attribute: `should_panic`:
132+
We can invert our test's failure with another attribute: `should_fail`:
133133

134134
```rust
135135
#[test]
136-
#[should_panic]
136+
#[should_fail]
137137
fn it_works() {
138138
assert!(false);
139139
}
@@ -163,13 +163,13 @@ equality:
163163

164164
```rust
165165
#[test]
166-
#[should_panic]
166+
#[should_fail]
167167
fn it_works() {
168168
assert_eq!("Hello", "world");
169169
}
170170
```
171171

172-
Does this test pass or fail? Because of the `should_panic` attribute, it
172+
Does this test pass or fail? Because of the `should_fail` attribute, it
173173
passes:
174174

175175
```bash
@@ -189,15 +189,15 @@ running 0 tests
189189
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
190190
```
191191

192-
`should_panic` tests can be fragile, as it's hard to guarantee that the test
192+
`should_fail` tests can be fragile, as it's hard to guarantee that the test
193193
didn't fail for an unexpected reason. To help with this, an optional `expected`
194-
parameter can be added to the `should_panic` attribute. The test harness will
194+
parameter can be added to the `should_fail` attribute. The test harness will
195195
make sure that the failure message contains the provided text. A safer version
196196
of the example above would be:
197197

198198
```
199199
#[test]
200-
#[should_panic(expected = "assertion failed")]
200+
#[should_fail(expected = "assertion failed")]
201201
fn it_works() {
202202
assert_eq!("Hello", "world");
203203
}

branches/try/src/libcollections/fmt.rs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//! This macro is implemented in the compiler to emit calls to this module in
1717
//! order to format arguments at runtime into strings and streams.
1818
//!
19-
//! ## Usage
19+
//! # Usage
2020
//!
2121
//! The `format!` macro is intended to be familiar to those coming from C's
2222
//! printf/fprintf functions or Python's `str.format` function. In its current
@@ -41,7 +41,7 @@
4141
//! will then parse the format string and determine if the list of arguments
4242
//! provided is suitable to pass to this format string.
4343
//!
44-
//! ### Positional parameters
44+
//! ## Positional parameters
4545
//!
4646
//! Each formatting argument is allowed to specify which value argument it's
4747
//! referencing, and if omitted it is assumed to be "the next argument". For
@@ -54,7 +54,7 @@
5454
//! iterator over the argument. Each time a "next argument" specifier is seen,
5555
//! the iterator advances. This leads to behavior like this:
5656
//!
57-
//! ```rust
57+
//! ```
5858
//! format!("{1} {} {0} {}", 1, 2); // => "2 1 1 2"
5959
//! ```
6060
//!
@@ -68,7 +68,7 @@
6868
//! compile-time error. You may refer to the same argument more than once in the
6969
//! format string, although it must always be referred to with the same type.
7070
//!
71-
//! ### Named parameters
71+
//! ## Named parameters
7272
//!
7373
//! Rust itself does not have a Python-like equivalent of named parameters to a
7474
//! function, but the `format!` macro is a syntax extension which allows it to
@@ -91,7 +91,7 @@
9191
//! arguments which have names. Like with positional parameters, it is illegal
9292
//! to provide named parameters that are unused by the format string.
9393
//!
94-
//! ### Argument types
94+
//! ## Argument types
9595
//!
9696
//! Each argument's type is dictated by the format string. It is a requirement
9797
//! that every argument is only ever referred to by one type. For example, this
@@ -116,7 +116,7 @@
116116
//! {:.*} {0}
117117
//! ```
118118
//!
119-
//! ### Formatting traits
119+
//! ## Formatting traits
120120
//!
121121
//! When requesting that an argument be formatted with a particular type, you
122122
//! are actually requesting that an argument ascribes to a particular trait.
@@ -142,7 +142,7 @@
142142
//! When implementing a format trait for your own type, you will have to
143143
//! implement a method of the signature:
144144
//!
145-
//! ```rust
145+
//! ```
146146
//! # use std::fmt;
147147
//! # struct Foo; // our custom type
148148
//! # impl fmt::Display for Foo {
@@ -166,7 +166,7 @@
166166
//! An example of implementing the formatting traits would look
167167
//! like:
168168
//!
169-
//! ```rust
169+
//! ```
170170
//! use std::fmt;
171171
//! use std::f64;
172172
//! use std::num::Float;
@@ -211,7 +211,7 @@
211211
//! }
212212
//! ```
213213
//!
214-
//! #### fmt::Display vs fmt::Debug
214+
//! ### fmt::Display vs fmt::Debug
215215
//!
216216
//! These two formatting traits have distinct purposes:
217217
//!
@@ -231,7 +231,7 @@
231231
//! assert_eq!(format!("{} {:?}", "foo\n", "bar\n"), "foo\n \"bar\\n\"");
232232
//! ```
233233
//!
234-
//! ### Related macros
234+
//! ## Related macros
235235
//!
236236
//! There are a number of related macros in the `format!` family. The ones that
237237
//! are currently implemented are:
@@ -245,32 +245,33 @@
245245
//! format_args! // described below.
246246
//! ```
247247
//!
248-
//! #### `write!`
248+
//! ### `write!`
249249
//!
250250
//! This and `writeln` are two macros which are used to emit the format string
251251
//! to a specified stream. This is used to prevent intermediate allocations of
252252
//! format strings and instead directly write the output. Under the hood, this
253253
//! function is actually invoking the `write` function defined in this module.
254254
//! Example usage is:
255255
//!
256-
//! ```rust
256+
//! ```
257257
//! # #![allow(unused_must_use)]
258258
//! let mut w = Vec::new();
259259
//! write!(&mut w, "Hello {}!", "world");
260260
//! ```
261261
//!
262-
//! #### `print!`
262+
//! ### `print!`
263263
//!
264264
//! This and `println` emit their output to stdout. Similarly to the `write!`
265265
//! macro, the goal of these macros is to avoid intermediate allocations when
266266
//! printing output. Example usage is:
267267
//!
268-
//! ```rust
268+
//! ```
269269
//! print!("Hello {}!", "world");
270270
//! println!("I have a newline {}", "character at the end");
271271
//! ```
272272
//!
273-
//! #### `format_args!`
273+
//! ### `format_args!`
274+
//!
274275
//! This is a curious macro which is used to safely pass around
275276
//! an opaque object describing the format string. This object
276277
//! does not require any heap allocations to create, and it only
@@ -303,7 +304,7 @@
303304
//! it would internally pass around this structure until it has been determined
304305
//! where output should go to.
305306
//!
306-
//! ## Syntax
307+
//! # Syntax
307308
//!
308309
//! The syntax for the formatting language used is drawn from other languages,
309310
//! so it should not be too alien. Arguments are formatted with python-like
@@ -326,14 +327,14 @@
326327
//! parameter := integer '$'
327328
//! ```
328329
//!
329-
//! ## Formatting Parameters
330+
//! # Formatting Parameters
330331
//!
331332
//! Each argument being formatted can be transformed by a number of formatting
332333
//! parameters (corresponding to `format_spec` in the syntax above). These
333334
//! parameters affect the string representation of what's being formatted. This
334335
//! syntax draws heavily from Python's, so it may seem a bit familiar.
335336
//!
336-
//! ### Fill/Alignment
337+
//! ## Fill/Alignment
337338
//!
338339
//! The fill character is provided normally in conjunction with the `width`
339340
//! parameter. This indicates that if the value being formatted is smaller than
@@ -345,7 +346,7 @@
345346
//! * `^` - the argument is center-aligned in `width` columns
346347
//! * `>` - the argument is right-aligned in `width` columns
347348
//!
348-
//! ### Sign/#/0
349+
//! ## Sign/#/0
349350
//!
350351
//! These can all be interpreted as flags for a particular formatter.
351352
//!
@@ -368,7 +369,7 @@
368369
//! same format would yield `-0000001` for the integer `-1`. Notice that
369370
//! the negative version has one fewer zero than the positive version.
370371
//!
371-
//! ### Width
372+
//! ## Width
372373
//!
373374
//! This is a parameter for the "minimum width" that the format should take up.
374375
//! If the value's string does not fill up this many characters, then the
@@ -384,7 +385,7 @@
384385
//! parameters by using the `2$` syntax indicating that the second argument is a
385386
//! `usize` specifying the width.
386387
//!
387-
//! ### Precision
388+
//! ## Precision
388389
//!
389390
//! For non-numeric types, this can be considered a "maximum width". If the
390391
//! resulting string is longer than this width, then it is truncated down to
@@ -395,7 +396,7 @@
395396
//! For floating-point types, this indicates how many digits after the decimal
396397
//! point should be printed.
397398
//!
398-
//! ## Escaping
399+
//! # Escaping
399400
//!
400401
//! The literal characters `{` and `}` may be included in a string by preceding
401402
//! them with the same character. For example, the `{` character is escaped with

branches/try/src/libcollectionstest/vec_deque.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ fn test_mut_rev_iter_wrap() {
360360
assert_eq!(d.pop_front(), Some(1));
361361
d.push_back(4);
362362

363-
assert_eq!(d.iter_mut().rev().map(|x| *x).collect::<Vec<_>>(),
363+
assert_eq!(d.iter_mut().rev().cloned().collect::<Vec<_>>(),
364364
vec![4, 3, 2]);
365365
}
366366

branches/try/src/libcore/iter.rs

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ use default::Default;
6565
use marker;
6666
use mem;
6767
use num::{ToPrimitive, Int};
68-
use ops::{Add, FnMut, RangeFrom};
68+
use ops::{Add, Deref, FnMut, RangeFrom};
6969
use option::Option;
7070
use option::Option::{Some, None};
7171
use marker::Sized;
@@ -976,11 +976,12 @@ pub trait IteratorExt: Iterator + Sized {
976976
(ts, us)
977977
}
978978

979-
/// Creates an iterator that clones the elements it yields. Useful for
980-
/// converting an Iterator<&T> to an Iterator<T>.
981-
#[stable(feature = "rust1", since = "1.0.0")]
982-
fn cloned<'a, T: 'a>(self) -> Cloned<Self>
983-
where Self: Iterator<Item=&'a T>, T: Clone
979+
/// Creates an iterator that clones the elements it yields. Useful for converting an
980+
/// Iterator<&T> to an Iterator<T>.
981+
#[unstable(feature = "core", reason = "recent addition")]
982+
fn cloned(self) -> Cloned<Self> where
983+
Self::Item: Deref,
984+
<Self::Item as Deref>::Target: Clone,
984985
{
985986
Cloned { it: self }
986987
}
@@ -1278,12 +1279,14 @@ pub struct Cloned<I> {
12781279
}
12791280

12801281
#[stable(feature = "rust1", since = "1.0.0")]
1281-
impl<'a, I, T: 'a> Iterator for Cloned<I>
1282-
where I: Iterator<Item=&'a T>, T: Clone
1282+
impl<I> Iterator for Cloned<I> where
1283+
I: Iterator,
1284+
I::Item: Deref,
1285+
<I::Item as Deref>::Target: Clone
12831286
{
1284-
type Item = T;
1287+
type Item = <I::Item as Deref>::Target;
12851288

1286-
fn next(&mut self) -> Option<T> {
1289+
fn next(&mut self) -> Option<<Self as Iterator>::Item> {
12871290
self.it.next().cloned()
12881291
}
12891292

@@ -1293,30 +1296,36 @@ impl<'a, I, T: 'a> Iterator for Cloned<I>
12931296
}
12941297

12951298
#[stable(feature = "rust1", since = "1.0.0")]
1296-
impl<'a, I, T: 'a> DoubleEndedIterator for Cloned<I>
1297-
where I: DoubleEndedIterator<Item=&'a T>, T: Clone
1299+
impl<I> DoubleEndedIterator for Cloned<I> where
1300+
I: DoubleEndedIterator,
1301+
I::Item: Deref,
1302+
<I::Item as Deref>::Target: Clone
12981303
{
1299-
fn next_back(&mut self) -> Option<T> {
1304+
fn next_back(&mut self) -> Option<<Self as Iterator>::Item> {
13001305
self.it.next_back().cloned()
13011306
}
13021307
}
13031308

13041309
#[stable(feature = "rust1", since = "1.0.0")]
1305-
impl<'a, I, T: 'a> ExactSizeIterator for Cloned<I>
1306-
where I: ExactSizeIterator<Item=&'a T>, T: Clone
1310+
impl<I> ExactSizeIterator for Cloned<I> where
1311+
I: ExactSizeIterator,
1312+
I::Item: Deref,
1313+
<I::Item as Deref>::Target: Clone
13071314
{}
13081315

13091316
#[unstable(feature = "core", reason = "trait is experimental")]
1310-
impl<'a, I, T: 'a> RandomAccessIterator for Cloned<I>
1311-
where I: RandomAccessIterator<Item=&'a T>, T: Clone
1317+
impl<I> RandomAccessIterator for Cloned<I> where
1318+
I: RandomAccessIterator,
1319+
I::Item: Deref,
1320+
<I::Item as Deref>::Target: Clone
13121321
{
13131322
#[inline]
13141323
fn indexable(&self) -> usize {
13151324
self.it.indexable()
13161325
}
13171326

13181327
#[inline]
1319-
fn idx(&mut self, index: usize) -> Option<T> {
1328+
fn idx(&mut self, index: usize) -> Option<<Self as Iterator>::Item> {
13201329
self.it.idx(index).cloned()
13211330
}
13221331
}

branches/try/src/libcore/result.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ impl<T, E> Result<T, E> {
330330
/// Convert from `Result<T, E>` to `Option<E>`
331331
///
332332
/// Converts `self` into an `Option<E>`, consuming `self`,
333-
/// and discarding the success value, if any.
333+
/// and discarding the value, if any.
334334
///
335335
/// # Examples
336336
///

0 commit comments

Comments
 (0)