Auto merge of #24349 - Manishearth:rollup, r=Manishearth

- Successful merges: #24072, #24233, #24321, #24339, #24341, #24342, #24347
- Failed merges:
This commit is contained in:
bors 2015-04-12 20:50:19 +00:00
commit c3947061d6
6 changed files with 80 additions and 18 deletions

View File

@ -273,8 +273,8 @@ not, because both the trait and the type aren't in our crate.
One last thing about traits: generic functions with a trait bound use
*monomorphization* (*mono*: one, *morph*: form), so they are statically
dispatched. What's that mean? Check out the chapter on [static and dynamic
dispatch](static-and-dynamic-dispatch.html) for more.
dispatched. What's that mean? Check out the chapter on [trait
objects](trait-objects.html) for more.
## Multiple trait bounds

View File

@ -2197,13 +2197,9 @@ impl<I> Iterator for Fuse<I> where I: Iterator {
if self.done {
None
} else {
match self.iter.next() {
None => {
self.done = true;
None
}
x => x
}
let next = self.iter.next();
self.done = next.is_none();
next
}
}
@ -2224,13 +2220,9 @@ impl<I> DoubleEndedIterator for Fuse<I> where I: DoubleEndedIterator {
if self.done {
None
} else {
match self.iter.next_back() {
None => {
self.done = true;
None
}
x => x
}
let next = self.iter.next_back();
self.done = next.is_none();
next
}
}
}

View File

@ -2705,7 +2705,7 @@ macro_rules! from_str_radix_float_impl {
///
/// # Return value
///
/// `Err(ParseIntError)` if the string did not represent a valid number. Otherwise,
/// `Err(ParseFloatError)` if the string did not represent a valid number.
/// Otherwise, `Ok(n)` where `n` is the floating-point number represented by `src`.
#[inline]
#[allow(deprecated)]
@ -2734,7 +2734,7 @@ macro_rules! from_str_radix_float_impl {
///
/// # Return value
///
/// `Err(ParseIntError)` if the string did not represent a valid number. Otherwise,
/// `Err(ParseFloatError)` if the string did not represent a valid number.
/// Otherwise, `Ok(n)` where `n` is the floating-point number represented by `src`.
fn from_str_radix(src: &str, radix: u32)
-> Result<$T, ParseFloatError> {

View File

@ -0,0 +1,15 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn main() {
let mut t = [1; 2];
t = [t[1] * 2, t[0] * 2];
assert_eq!(&t[..], &[2, 2]);
}

View File

@ -0,0 +1,21 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct A {
pub x: u32,
pub y: u32,
}
fn main() {
let mut a = A { x: 1, y: 1 };
a = A { x: a.y * 2, y: a.x * 2 };
assert_eq!(a.x, 2);
assert_eq!(a.y, 2);
}

View File

@ -0,0 +1,34 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[derive(Debug)]
enum Foo {
Bar(u32, u32),
Baz(&'static u32, &'static u32)
}
static NUM: u32 = 100;
fn main () {
let mut b = Foo::Baz(&NUM, &NUM);
b = Foo::Bar(f(&b), g(&b));
}
static FNUM: u32 = 1;
fn f (b: &Foo) -> u32 {
FNUM
}
static GNUM: u32 = 2;
fn g (b: &Foo) -> u32 {
GNUM
}