Skip to content

Commit 89ad8fb

Browse files
committed
---
yaml --- r: 206399 b: refs/heads/beta c: 4fb2216 h: refs/heads/master i: 206397: e354c6e 206395: eb56b86 206391: 6475174 206383: 4c197b5 206367: 50a5c6f 206335: 43d6830 v: v3
1 parent 996bb83 commit 89ad8fb

38 files changed

+402
-230
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2929
refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3030
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3131
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
32-
refs/heads/beta: 86de427b2556d0f349ed0d31d0529ff9f241b9c9
32+
refs/heads/beta: 4fb22164a25a90543474d33fd51159e80806c9c5
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3535
refs/heads/tmp: 579e31929feff51dcaf8d444648eff8de735f91a

branches/beta/src/doc/trpl/error-handling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ struct Info {
252252
}
253253

254254
fn write_info(info: &Info) -> io::Result<()> {
255-
let mut file = File::open("my_best_friends.txt").unwrap();
255+
let mut file = File::create("my_best_friends.txt").unwrap();
256256

257257
if let Err(e) = writeln!(&mut file, "name: {}", info.name) {
258258
return Err(e)
@@ -282,7 +282,7 @@ struct Info {
282282
}
283283

284284
fn write_info(info: &Info) -> io::Result<()> {
285-
let mut file = try!(File::open("my_best_friends.txt"));
285+
let mut file = try!(File::create("my_best_friends.txt"));
286286

287287
try!(writeln!(&mut file, "name: {}", info.name));
288288
try!(writeln!(&mut file, "age: {}", info.age));

branches/beta/src/etc/extract_grammar.py

Lines changed: 0 additions & 156 deletions
This file was deleted.

branches/beta/src/libcollections/vec.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,43 @@
1515
//!
1616
//! # Examples
1717
//!
18-
//! Explicitly creating a `Vec<T>` with `new()`:
18+
//! You can explicitly create a `Vec<T>` with `new()`:
1919
//!
2020
//! ```
2121
//! let xs: Vec<i32> = Vec::new();
2222
//! ```
2323
//!
24-
//! Using the `vec!` macro:
24+
//! ...or by using the `vec!` macro:
2525
//!
2626
//! ```
2727
//! let ys: Vec<i32> = vec![];
2828
//!
2929
//! let zs = vec![1i32, 2, 3, 4, 5];
3030
//! ```
3131
//!
32-
//! Push:
32+
//! You can `push` values onto the end of a vector (which will grow the vector as needed):
3333
//!
3434
//! ```
3535
//! let mut xs = vec![1i32, 2];
3636
//!
3737
//! xs.push(3);
3838
//! ```
3939
//!
40-
//! And pop:
40+
//! Popping values works in much the same way:
4141
//!
4242
//! ```
4343
//! let mut xs = vec![1i32, 2];
4444
//!
4545
//! let two = xs.pop();
4646
//! ```
47+
//!
48+
//! Vectors also support indexing (through the `Index` and `IndexMut` traits):
49+
//!
50+
//! ```
51+
//! let mut xs = vec![1i32, 2, 3];
52+
//! let three = xs[2];
53+
//! xs[1] = xs[1] + 5;
54+
//! ```
4755
4856
#![stable(feature = "rust1", since = "1.0.0")]
4957

branches/beta/src/librustc_trans/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ fn add_local_native_libraries(cmd: &mut Command, sess: &Session) {
10781078
sess.target_filesearch(PathKind::All).for_each_lib_search_path(|path, k| {
10791079
match k {
10801080
PathKind::Framework => { cmd.arg("-F").arg(path); }
1081-
_ => { cmd.arg("-L").arg(path); }
1081+
_ => { cmd.arg("-L").arg(&fix_windows_verbatim_for_gcc(path)); }
10821082
}
10831083
FileDoesntMatch
10841084
});

branches/beta/src/libstd/collections/hash/map.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,9 @@ fn test_resize_policy() {
212212
/// overridden with one of the constructors.
213213
///
214214
/// It is required that the keys implement the `Eq` and `Hash` traits, although
215-
/// this can frequently be achieved by using `#[derive(Eq, Hash)]`. If you
216-
/// implement these yourself, it is important that the following property holds:
215+
/// this can frequently be achieved by using `#[derive(PartialEq, Eq, Hash)]`.
216+
/// If you implement these yourself, it is important that the following
217+
/// property holds:
217218
///
218219
/// ```text
219220
/// k1 == k2 -> hash(k1) == hash(k2)
@@ -250,26 +251,26 @@ fn test_resize_policy() {
250251
/// book_reviews.insert("The Adventures of Sherlock Holmes", "Eye lyked it alot.");
251252
///
252253
/// // check for a specific one.
253-
/// if !book_reviews.contains_key(&("Les Misérables")) {
254+
/// if !book_reviews.contains_key("Les Misérables") {
254255
/// println!("We've got {} reviews, but Les Misérables ain't one.",
255256
/// book_reviews.len());
256257
/// }
257258
///
258259
/// // oops, this review has a lot of spelling mistakes, let's delete it.
259-
/// book_reviews.remove(&("The Adventures of Sherlock Holmes"));
260+
/// book_reviews.remove("The Adventures of Sherlock Holmes");
260261
///
261262
/// // look up the values associated with some keys.
262263
/// let to_find = ["Pride and Prejudice", "Alice's Adventure in Wonderland"];
263-
/// for book in to_find.iter() {
264+
/// for book in &to_find {
264265
/// match book_reviews.get(book) {
265-
/// Some(review) => println!("{}: {}", *book, *review),
266-
/// None => println!("{} is unreviewed.", *book)
266+
/// Some(review) => println!("{}: {}", book, review),
267+
/// None => println!("{} is unreviewed.", book)
267268
/// }
268269
/// }
269270
///
270271
/// // iterate over everything.
271-
/// for (book, review) in book_reviews.iter() {
272-
/// println!("{}: \"{}\"", *book, *review);
272+
/// for (book, review) in &book_reviews {
273+
/// println!("{}: \"{}\"", book, review);
273274
/// }
274275
/// ```
275276
///
@@ -300,7 +301,7 @@ fn test_resize_policy() {
300301
/// vikings.insert(Viking::new("Harald", "Iceland"), 12);
301302
///
302303
/// // Use derived implementation to print the status of the vikings.
303-
/// for (viking, health) in vikings.iter() {
304+
/// for (viking, health) in &vikings {
304305
/// println!("{:?} has {} hp", viking, health);
305306
/// }
306307
/// ```

branches/beta/src/libstd/collections/hash/set.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ use super::state::HashState;
3131
// to get rid of it properly.
3232

3333
/// An implementation of a hash set using the underlying representation of a
34-
/// HashMap where the value is (). As with the `HashMap` type, a `HashSet`
35-
/// requires that the elements implement the `Eq` and `Hash` traits. This can
36-
/// frequently be achieved by using `#[derive(Eq, Hash)]`. If you implement
37-
/// these yourself, it is important that the following property holds:
34+
/// HashMap where the value is ().
35+
///
36+
/// As with the `HashMap` type, a `HashSet` requires that the elements
37+
/// implement the `Eq` and `Hash` traits. This can frequently be achieved by
38+
/// using `#[derive(PartialEq, Eq, Hash)]`. If you implement these yourself,
39+
/// it is important that the following property holds:
3840
///
3941
/// ```text
4042
/// k1 == k2 -> hash(k1) == hash(k2)
@@ -64,17 +66,17 @@ use super::state::HashState;
6466
/// books.insert("The Great Gatsby");
6567
///
6668
/// // Check for a specific one.
67-
/// if !books.contains(&("The Winds of Winter")) {
69+
/// if !books.contains("The Winds of Winter") {
6870
/// println!("We have {} books, but The Winds of Winter ain't one.",
6971
/// books.len());
7072
/// }
7173
///
7274
/// // Remove a book.
73-
/// books.remove(&"The Odyssey");
75+
/// books.remove("The Odyssey");
7476
///
7577
/// // Iterate over everything.
76-
/// for book in books.iter() {
77-
/// println!("{}", *book);
78+
/// for book in &books {
79+
/// println!("{}", book);
7880
/// }
7981
/// ```
8082
///
@@ -98,7 +100,7 @@ use super::state::HashState;
98100
/// vikings.insert(Viking { name: "Harald", power: 8 });
99101
///
100102
/// // Use derived implementation to print the vikings.
101-
/// for x in vikings.iter() {
103+
/// for x in &vikings {
102104
/// println!("{:?}", x);
103105
/// }
104106
/// ```

branches/beta/src/libstd/net/ip.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ impl Ipv4Addr {
174174
((self.octets()[0] as u16) << 8) | self.octets()[1] as u16,
175175
((self.octets()[2] as u16) << 8) | self.octets()[3] as u16)
176176
}
177-
178177
}
179178

180179
#[stable(feature = "rust1", since = "1.0.0")]
@@ -247,6 +246,21 @@ impl FromInner<libc::in_addr> for Ipv4Addr {
247246
}
248247
}
249248

249+
#[stable(feature = "ip_u32", since = "1.1.0")]
250+
impl From<Ipv4Addr> for u32 {
251+
fn from(ip: Ipv4Addr) -> u32 {
252+
let ip = ip.octets();
253+
((ip[0] as u32) << 24) + ((ip[1] as u32) << 16) + ((ip[2] as u32) << 8) + (ip[3] as u32)
254+
}
255+
}
256+
257+
#[stable(feature = "ip_u32", since = "1.1.0")]
258+
impl From<u32> for Ipv4Addr {
259+
fn from(ip: u32) -> Ipv4Addr {
260+
Ipv4Addr::new((ip >> 24) as u8, (ip >> 16) as u8, (ip >> 8) as u8, ip as u8)
261+
}
262+
}
263+
250264
impl Ipv6Addr {
251265
/// Creates a new IPv6 address from eight 16-bit segments.
252266
///
@@ -746,4 +760,16 @@ mod tests {
746760
let a = sa4(Ipv4Addr::new(77, 88, 21, 11), 12345);
747761
assert_eq!(Ok(vec![a]), tsa(a));
748762
}
763+
764+
#[test]
765+
fn test_ipv4_to_int() {
766+
let a = Ipv4Addr::new(127, 0, 0, 1);
767+
assert_eq!(u32::from(a), 2130706433);
768+
}
769+
770+
#[test]
771+
fn test_int_to_ipv4() {
772+
let a = Ipv4Addr::new(127, 0, 0, 1);
773+
assert_eq!(Ipv4Addr::from(2130706433), a);
774+
}
749775
}

branches/beta/src/libstd/net/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ mod parser;
3232

3333
/// Possible values which can be passed to the `shutdown` method of `TcpStream`
3434
/// and `UdpSocket`.
35-
#[derive(Copy, Clone, PartialEq)]
35+
#[derive(Copy, Clone, PartialEq, Debug)]
3636
#[stable(feature = "rust1", since = "1.0.0")]
3737
pub enum Shutdown {
3838
/// Indicates that the reading portion of this stream/socket should be shut

0 commit comments

Comments
 (0)