mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
std: Stabilize the prelude module
This commit is an implementation of [RFC 503][rfc] which is a stabilization story for the prelude. Most of the RFC was directly applied, removing reexports. Some reexports are kept around, however: * `range` remains until range syntax has landed to reduce churn. * `Path` and `GenericPath` remain until path reform lands. This is done to prevent many imports of `GenericPath` which will soon be removed. * All `io` traits remain until I/O reform lands so imports can be rewritten all at once to `std::io::prelude::*`. This is a breaking change because many prelude reexports have been removed, and the RFC can be consulted for the exact list of removed reexports, as well as to find the locations of where to import them. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0503-prelude-stabilization.md [breaking-change] Closes #20068
This commit is contained in:
parent
71b46b18a2
commit
56290a0044
@ -22,8 +22,8 @@ extern crate regex;
|
||||
use std::os;
|
||||
use std::io;
|
||||
use std::io::fs;
|
||||
use std::str::FromStr;
|
||||
use std::thunk::{Thunk};
|
||||
use std::str::{FromStr, from_str};
|
||||
use std::thunk::Thunk;
|
||||
use getopts::{optopt, optflag, reqopt};
|
||||
use common::Config;
|
||||
use common::{Pretty, DebugInfoGdb, DebugInfoLldb, Codegen};
|
||||
|
@ -450,6 +450,8 @@ them.
|
||||
|
||||
~~~no_run
|
||||
extern crate libc;
|
||||
|
||||
use std::c_str::ToCStr;
|
||||
use std::ptr;
|
||||
|
||||
#[link(name = "readline")]
|
||||
|
173
src/doc/guide.md
173
src/doc/guide.md
@ -26,7 +26,7 @@ in the `$`s, they just indicate the start of each command):
|
||||
curl -L https://static.rust-lang.org/rustup.sh | sudo sh
|
||||
```
|
||||
|
||||
If you're concerned about the [potential insecurity](http://curlpipesh.tumblr.com/) of using `curl | sudo sh`,
|
||||
If you're concerned about the [potential insecurity](http://curlpipesh.tumblr.com/) of using `curl | sudo sh`,
|
||||
please keep reading and see our disclaimer below. And feel free to use a two-step version of the installation and examine our installation script:
|
||||
|
||||
```bash
|
||||
@ -1109,10 +1109,11 @@ An `Ordering` can only be _one_ of `Less`, `Equal`, or `Greater` at any given
|
||||
time. Here's an example:
|
||||
|
||||
```{rust}
|
||||
# use std::cmp::Ordering;
|
||||
fn cmp(a: int, b: int) -> Ordering {
|
||||
if a < b { Less }
|
||||
else if a > b { Greater }
|
||||
else { Equal }
|
||||
if a < b { Ordering::Less }
|
||||
else if a > b { Ordering::Greater }
|
||||
else { Ordering::Equal }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@ -1121,11 +1122,11 @@ fn main() {
|
||||
|
||||
let ordering = cmp(x, y); // ordering: Ordering
|
||||
|
||||
if ordering == Less {
|
||||
if ordering == Ordering::Less {
|
||||
println!("less");
|
||||
} else if ordering == Greater {
|
||||
} else if ordering == Ordering::Greater {
|
||||
println!("greater");
|
||||
} else if ordering == Equal {
|
||||
} else if ordering == Ordering::Equal {
|
||||
println!("equal");
|
||||
}
|
||||
}
|
||||
@ -1280,10 +1281,11 @@ for every possible value of `x`, and so our program will compile successfully.
|
||||
section on enums?
|
||||
|
||||
```{rust}
|
||||
# use std::cmp::Ordering;
|
||||
fn cmp(a: int, b: int) -> Ordering {
|
||||
if a < b { Less }
|
||||
else if a > b { Greater }
|
||||
else { Equal }
|
||||
if a < b { Ordering::Less }
|
||||
else if a > b { Ordering::Greater }
|
||||
else { Ordering::Equal }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@ -1292,11 +1294,11 @@ fn main() {
|
||||
|
||||
let ordering = cmp(x, y);
|
||||
|
||||
if ordering == Less {
|
||||
if ordering == Ordering::Less {
|
||||
println!("less");
|
||||
} else if ordering == Greater {
|
||||
} else if ordering == Ordering::Greater {
|
||||
println!("greater");
|
||||
} else if ordering == Equal {
|
||||
} else if ordering == Ordering::Equal {
|
||||
println!("equal");
|
||||
}
|
||||
}
|
||||
@ -1305,10 +1307,11 @@ fn main() {
|
||||
We can re-write this as a `match`:
|
||||
|
||||
```{rust}
|
||||
# use std::cmp::Ordering;
|
||||
fn cmp(a: int, b: int) -> Ordering {
|
||||
if a < b { Less }
|
||||
else if a > b { Greater }
|
||||
else { Equal }
|
||||
if a < b { Ordering::Less }
|
||||
else if a > b { Ordering::Greater }
|
||||
else { Ordering::Equal }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@ -1316,9 +1319,9 @@ fn main() {
|
||||
let y = 10i;
|
||||
|
||||
match cmp(x, y) {
|
||||
Less => println!("less"),
|
||||
Greater => println!("greater"),
|
||||
Equal => println!("equal"),
|
||||
Ordering::Less => println!("less"),
|
||||
Ordering::Greater => println!("greater"),
|
||||
Ordering::Equal => println!("equal"),
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -1365,10 +1368,11 @@ side of a `let` binding or directly where an expression is used. We could
|
||||
also implement the previous line like this:
|
||||
|
||||
```{rust}
|
||||
# use std::cmp::Ordering;
|
||||
fn cmp(a: int, b: int) -> Ordering {
|
||||
if a < b { Less }
|
||||
else if a > b { Greater }
|
||||
else { Equal }
|
||||
if a < b { Ordering::Less }
|
||||
else if a > b { Ordering::Greater }
|
||||
else { Ordering::Equal }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@ -1376,9 +1380,9 @@ fn main() {
|
||||
let y = 10i;
|
||||
|
||||
println!("{}", match cmp(x, y) {
|
||||
Less => "less",
|
||||
Greater => "greater",
|
||||
Equal => "equal",
|
||||
Ordering::Less => "less",
|
||||
Ordering::Greater => "greater",
|
||||
Ordering::Equal => "equal",
|
||||
});
|
||||
}
|
||||
```
|
||||
@ -2139,6 +2143,7 @@ guess to the secret number:
|
||||
```{rust,ignore}
|
||||
use std::io;
|
||||
use std::rand;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
fn main() {
|
||||
println!("Guess the number!");
|
||||
@ -2157,16 +2162,16 @@ fn main() {
|
||||
println!("You guessed: {}", input);
|
||||
|
||||
match cmp(input, secret_number) {
|
||||
Less => println!("Too small!"),
|
||||
Greater => println!("Too big!"),
|
||||
Equal => println!("You win!"),
|
||||
Ordering::Less => println!("Too small!"),
|
||||
Ordering::Greater => println!("Too big!"),
|
||||
Ordering::Equal => println!("You win!"),
|
||||
}
|
||||
}
|
||||
|
||||
fn cmp(a: int, b: int) -> Ordering {
|
||||
if a < b { Less }
|
||||
else if a > b { Greater }
|
||||
else { Equal }
|
||||
if a < b { Ordering::Less }
|
||||
else if a > b { Ordering::Greater }
|
||||
else { Ordering::Equal }
|
||||
}
|
||||
```
|
||||
|
||||
@ -2193,6 +2198,7 @@ we wrote the `cmp` function! Let's change it to take `uint`s:
|
||||
```{rust,ignore}
|
||||
use std::io;
|
||||
use std::rand;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
fn main() {
|
||||
println!("Guess the number!");
|
||||
@ -2211,16 +2217,16 @@ fn main() {
|
||||
println!("You guessed: {}", input);
|
||||
|
||||
match cmp(input, secret_number) {
|
||||
Less => println!("Too small!"),
|
||||
Greater => println!("Too big!"),
|
||||
Equal => println!("You win!"),
|
||||
Ordering::Less => println!("Too small!"),
|
||||
Ordering::Greater => println!("Too big!"),
|
||||
Ordering::Equal => println!("You win!"),
|
||||
}
|
||||
}
|
||||
|
||||
fn cmp(a: uint, b: uint) -> Ordering {
|
||||
if a < b { Less }
|
||||
else if a > b { Greater }
|
||||
else { Equal }
|
||||
if a < b { Ordering::Less }
|
||||
else if a > b { Ordering::Greater }
|
||||
else { Ordering::Equal }
|
||||
}
|
||||
```
|
||||
|
||||
@ -2290,6 +2296,7 @@ Anyway, with us now converting our input to a number, our code looks like this:
|
||||
```{rust,ignore}
|
||||
use std::io;
|
||||
use std::rand;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
fn main() {
|
||||
println!("Guess the number!");
|
||||
@ -2308,16 +2315,16 @@ fn main() {
|
||||
println!("You guessed: {}", input_num);
|
||||
|
||||
match cmp(input_num, secret_number) {
|
||||
Less => println!("Too small!"),
|
||||
Greater => println!("Too big!"),
|
||||
Equal => println!("You win!"),
|
||||
Ordering::Less => println!("Too small!"),
|
||||
Ordering::Greater => println!("Too big!"),
|
||||
Ordering::Equal => println!("You win!"),
|
||||
}
|
||||
}
|
||||
|
||||
fn cmp(a: uint, b: uint) -> Ordering {
|
||||
if a < b { Less }
|
||||
else if a > b { Greater }
|
||||
else { Equal }
|
||||
if a < b { Ordering::Less }
|
||||
else if a > b { Ordering::Greater }
|
||||
else { Ordering::Equal }
|
||||
}
|
||||
```
|
||||
|
||||
@ -2339,6 +2346,7 @@ to do that. Try this code:
|
||||
```{rust,no_run}
|
||||
use std::io;
|
||||
use std::rand;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
fn main() {
|
||||
println!("Guess the number!");
|
||||
@ -2366,16 +2374,16 @@ fn main() {
|
||||
println!("You guessed: {}", num);
|
||||
|
||||
match cmp(num, secret_number) {
|
||||
Less => println!("Too small!"),
|
||||
Greater => println!("Too big!"),
|
||||
Equal => println!("You win!"),
|
||||
Ordering::Less => println!("Too small!"),
|
||||
Ordering::Greater => println!("Too big!"),
|
||||
Ordering::Equal => println!("You win!"),
|
||||
}
|
||||
}
|
||||
|
||||
fn cmp(a: uint, b: uint) -> Ordering {
|
||||
if a < b { Less }
|
||||
else if a > b { Greater }
|
||||
else { Equal }
|
||||
if a < b { Ordering::Less }
|
||||
else if a > b { Ordering::Greater }
|
||||
else { Ordering::Equal }
|
||||
}
|
||||
```
|
||||
|
||||
@ -2405,6 +2413,7 @@ code looks like this:
|
||||
```{rust,no_run}
|
||||
use std::io;
|
||||
use std::rand;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
fn main() {
|
||||
println!("Guess the number!");
|
||||
@ -2432,16 +2441,16 @@ fn main() {
|
||||
println!("You guessed: {}", num);
|
||||
|
||||
match cmp(num, secret_number) {
|
||||
Less => println!("Too small!"),
|
||||
Greater => println!("Too big!"),
|
||||
Equal => println!("You win!"),
|
||||
Ordering::Less => println!("Too small!"),
|
||||
Ordering::Greater => println!("Too big!"),
|
||||
Ordering::Equal => println!("You win!"),
|
||||
}
|
||||
}
|
||||
|
||||
fn cmp(a: uint, b: uint) -> Ordering {
|
||||
if a < b { Less }
|
||||
else if a > b { Greater }
|
||||
else { Equal }
|
||||
if a < b { Ordering::Less }
|
||||
else if a > b { Ordering::Greater }
|
||||
else { Ordering::Equal }
|
||||
}
|
||||
```
|
||||
|
||||
@ -2478,6 +2487,7 @@ Let's add that in:
|
||||
```{rust,no_run}
|
||||
use std::io;
|
||||
use std::rand;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
fn main() {
|
||||
println!("Guess the number!");
|
||||
@ -2507,17 +2517,17 @@ fn main() {
|
||||
println!("You guessed: {}", num);
|
||||
|
||||
match cmp(num, secret_number) {
|
||||
Less => println!("Too small!"),
|
||||
Greater => println!("Too big!"),
|
||||
Equal => println!("You win!"),
|
||||
Ordering::Less => println!("Too small!"),
|
||||
Ordering::Greater => println!("Too big!"),
|
||||
Ordering::Equal => println!("You win!"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn cmp(a: uint, b: uint) -> Ordering {
|
||||
if a < b { Less }
|
||||
else if a > b { Greater }
|
||||
else { Equal }
|
||||
if a < b { Ordering::Less }
|
||||
else if a > b { Ordering::Greater }
|
||||
else { Ordering::Equal }
|
||||
}
|
||||
```
|
||||
|
||||
@ -2553,6 +2563,7 @@ suboptimal to say the least. First, let's actually quit when you win the game:
|
||||
```{rust,no_run}
|
||||
use std::io;
|
||||
use std::rand;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
fn main() {
|
||||
println!("Guess the number!");
|
||||
@ -2582,9 +2593,9 @@ fn main() {
|
||||
println!("You guessed: {}", num);
|
||||
|
||||
match cmp(num, secret_number) {
|
||||
Less => println!("Too small!"),
|
||||
Greater => println!("Too big!"),
|
||||
Equal => {
|
||||
Ordering::Less => println!("Too small!"),
|
||||
Ordering::Greater => println!("Too big!"),
|
||||
Ordering::Equal => {
|
||||
println!("You win!");
|
||||
return;
|
||||
},
|
||||
@ -2593,9 +2604,9 @@ fn main() {
|
||||
}
|
||||
|
||||
fn cmp(a: uint, b: uint) -> Ordering {
|
||||
if a < b { Less }
|
||||
else if a > b { Greater }
|
||||
else { Equal }
|
||||
if a < b { Ordering::Less }
|
||||
else if a > b { Ordering::Greater }
|
||||
else { Ordering::Equal }
|
||||
}
|
||||
```
|
||||
|
||||
@ -2608,6 +2619,7 @@ we don't want to quit, we just want to ignore it. Change that `return` to
|
||||
```{rust,no_run}
|
||||
use std::io;
|
||||
use std::rand;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
fn main() {
|
||||
println!("Guess the number!");
|
||||
@ -2637,9 +2649,9 @@ fn main() {
|
||||
println!("You guessed: {}", num);
|
||||
|
||||
match cmp(num, secret_number) {
|
||||
Less => println!("Too small!"),
|
||||
Greater => println!("Too big!"),
|
||||
Equal => {
|
||||
Ordering::Less => println!("Too small!"),
|
||||
Ordering::Greater => println!("Too big!"),
|
||||
Ordering::Equal => {
|
||||
println!("You win!");
|
||||
return;
|
||||
},
|
||||
@ -2648,9 +2660,9 @@ fn main() {
|
||||
}
|
||||
|
||||
fn cmp(a: uint, b: uint) -> Ordering {
|
||||
if a < b { Less }
|
||||
else if a > b { Greater }
|
||||
else { Equal }
|
||||
if a < b { Ordering::Less }
|
||||
else if a > b { Ordering::Greater }
|
||||
else { Ordering::Equal }
|
||||
}
|
||||
```
|
||||
|
||||
@ -2686,6 +2698,7 @@ It was good for testing, but it kind of ruins the game. Here's our final source:
|
||||
```{rust,no_run}
|
||||
use std::io;
|
||||
use std::rand;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
fn main() {
|
||||
println!("Guess the number!");
|
||||
@ -2713,9 +2726,9 @@ fn main() {
|
||||
println!("You guessed: {}", num);
|
||||
|
||||
match cmp(num, secret_number) {
|
||||
Less => println!("Too small!"),
|
||||
Greater => println!("Too big!"),
|
||||
Equal => {
|
||||
Ordering::Less => println!("Too small!"),
|
||||
Ordering::Greater => println!("Too big!"),
|
||||
Ordering::Equal => {
|
||||
println!("You win!");
|
||||
return;
|
||||
},
|
||||
@ -2724,9 +2737,9 @@ fn main() {
|
||||
}
|
||||
|
||||
fn cmp(a: uint, b: uint) -> Ordering {
|
||||
if a < b { Less }
|
||||
else if a > b { Greater }
|
||||
else { Equal }
|
||||
if a < b { Ordering::Less }
|
||||
else if a > b { Ordering::Greater }
|
||||
else { Ordering::Equal }
|
||||
}
|
||||
```
|
||||
|
||||
@ -5217,7 +5230,7 @@ as you can see, there's no overhead of deciding which version to call here,
|
||||
hence 'statically dispatched'. The downside is that we have two copies of
|
||||
the same function, so our binary is a little bit larger.
|
||||
|
||||
# Threads
|
||||
# Threads
|
||||
|
||||
Concurrency and parallelism are topics that are of increasing interest to a
|
||||
broad subsection of software developers. Modern computers are often multi-core,
|
||||
|
@ -4149,11 +4149,11 @@ Unwinding the stack of a thread is done by the thread itself, on its own control
|
||||
stack. If a value with a destructor is freed during unwinding, the code for the
|
||||
destructor is run, also on the thread's control stack. Running the destructor
|
||||
code causes a temporary transition to a *running* state, and allows the
|
||||
destructor code to cause any subsequent state transitions. The original thread
|
||||
destructor code to cause any subsequent state transitions. The original thread
|
||||
of unwinding and panicking thereby may suspend temporarily, and may involve
|
||||
(recursive) unwinding of the stack of a failed destructor. Nonetheless, the
|
||||
outermost unwinding activity will continue until the stack is unwound and the
|
||||
thread transitions to the *dead* state. There is no way to "recover" from thread
|
||||
thread transitions to the *dead* state. There is no way to "recover" from thread
|
||||
panics. Once a thread has temporarily suspended its unwinding in the *panicking*
|
||||
state, a panic occurring from within this destructor results in *hard* panic.
|
||||
A hard panic currently results in the process aborting.
|
||||
|
@ -26,6 +26,7 @@
|
||||
//! [dir_graph]: http://en.wikipedia.org/wiki/Directed_graph
|
||||
//!
|
||||
//! ```
|
||||
//! use std::cmp::Ordering;
|
||||
//! use std::collections::BinaryHeap;
|
||||
//! use std::uint;
|
||||
//!
|
||||
@ -151,6 +152,7 @@
|
||||
use core::prelude::*;
|
||||
|
||||
use core::default::Default;
|
||||
use core::iter::FromIterator;
|
||||
use core::mem::{zeroed, replace, swap};
|
||||
use core::ptr;
|
||||
|
||||
|
@ -82,17 +82,19 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use core::cmp::Ordering;
|
||||
use core::cmp;
|
||||
use core::default::Default;
|
||||
use core::fmt;
|
||||
use core::hash;
|
||||
use core::iter::{Cloned, Chain, Enumerate, Repeat, Skip, Take, repeat};
|
||||
use core::iter;
|
||||
use core::iter::{mod, FromIterator, RandomAccessIterator};
|
||||
use core::num::Int;
|
||||
use core::slice;
|
||||
use core::ops::Index;
|
||||
use core::slice::{Iter, IterMut};
|
||||
use core::{u8, u32, uint};
|
||||
use bitv_set; //so meta
|
||||
|
||||
use core::hash;
|
||||
use Vec;
|
||||
|
||||
type Blocks<'a> = Cloned<slice::Iter<'a, u32>>;
|
||||
@ -2507,7 +2509,7 @@ mod tests {
|
||||
|
||||
#[cfg(test)]
|
||||
mod bitv_bench {
|
||||
use std::prelude::*;
|
||||
use std::prelude::v1::*;
|
||||
use std::rand;
|
||||
use std::rand::Rng;
|
||||
use std::u32;
|
||||
@ -3002,7 +3004,7 @@ mod bitv_set_test {
|
||||
|
||||
#[cfg(test)]
|
||||
mod bitv_set_bench {
|
||||
use std::prelude::*;
|
||||
use std::prelude::v1::*;
|
||||
use std::rand;
|
||||
use std::rand::Rng;
|
||||
use std::u32;
|
||||
|
@ -19,21 +19,23 @@ pub use self::Entry::*;
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use self::StackOp::*;
|
||||
use super::node::{mod, Node, Found, GoDown};
|
||||
use super::node::{Traversal, MutTraversal, MoveTraversal};
|
||||
use super::node::TraversalItem::{mod, Elem, Edge};
|
||||
use super::node::ForceResult::{Leaf, Internal};
|
||||
use core::borrow::BorrowFrom;
|
||||
use std::hash::{Writer, Hash};
|
||||
use core::cmp::Ordering;
|
||||
use core::default::Default;
|
||||
use core::{iter, fmt, mem};
|
||||
use core::fmt::Show;
|
||||
use core::iter::Map;
|
||||
use core::hash::{Writer, Hash};
|
||||
use core::iter::{Map, FromIterator};
|
||||
use core::ops::{Index, IndexMut};
|
||||
use core::{iter, fmt, mem};
|
||||
|
||||
use ring_buf::RingBuf;
|
||||
|
||||
use self::Continuation::{Continue, Finished};
|
||||
use self::StackOp::*;
|
||||
use super::node::ForceResult::{Leaf, Internal};
|
||||
use super::node::TraversalItem::{mod, Elem, Edge};
|
||||
use super::node::{Traversal, MutTraversal, MoveTraversal};
|
||||
use super::node::{mod, Node, Found, GoDown};
|
||||
|
||||
// FIXME(conventions): implement bounded iterators
|
||||
|
||||
@ -501,6 +503,7 @@ mod stack {
|
||||
use core::prelude::*;
|
||||
use core::kinds::marker;
|
||||
use core::mem;
|
||||
use core::ops::{Deref, DerefMut};
|
||||
use super::BTreeMap;
|
||||
use super::super::node::{mod, Node, Fit, Split, Internal, Leaf};
|
||||
use super::super::node::handle;
|
||||
|
@ -18,10 +18,12 @@ pub use self::TraversalItem::*;
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use core::{slice, mem, ptr, cmp, num, raw};
|
||||
use core::iter::Zip;
|
||||
use core::borrow::BorrowFrom;
|
||||
use core::cmp::Ordering::{Greater, Less, Equal};
|
||||
use core::iter::Zip;
|
||||
use core::ops::{Deref, DerefMut};
|
||||
use core::ptr::Unique;
|
||||
use core::{slice, mem, ptr, cmp, num, raw};
|
||||
use alloc::heap;
|
||||
|
||||
/// Represents the result of an Insertion: either the item fit, or the node had to split
|
||||
|
@ -13,13 +13,16 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use btree_map::{BTreeMap, Keys};
|
||||
use std::hash::Hash;
|
||||
use core::borrow::BorrowFrom;
|
||||
use core::cmp::Ordering::{mod, Less, Greater, Equal};
|
||||
use core::default::Default;
|
||||
use core::fmt;
|
||||
use core::iter::{Peekable, Map};
|
||||
use core::fmt::Show;
|
||||
use core::fmt;
|
||||
use core::hash::Hash;
|
||||
use core::iter::{Peekable, Map, FromIterator};
|
||||
use core::ops::{BitOr, BitAnd, BitXor, Sub};
|
||||
|
||||
use btree_map::{BTreeMap, Keys};
|
||||
|
||||
// FIXME(conventions): implement bounded iterators
|
||||
|
||||
|
@ -22,12 +22,13 @@
|
||||
use core::prelude::*;
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use core::cmp::Ordering;
|
||||
use core::default::Default;
|
||||
use core::fmt;
|
||||
use core::iter;
|
||||
use core::hash::{Writer, Hash};
|
||||
use core::iter::{mod, FromIterator};
|
||||
use core::mem;
|
||||
use core::ptr;
|
||||
use std::hash::{Writer, Hash};
|
||||
|
||||
/// A doubly-linked list.
|
||||
#[stable]
|
||||
|
@ -16,6 +16,8 @@
|
||||
use core::prelude::*;
|
||||
use core::fmt;
|
||||
use core::num::Int;
|
||||
use core::iter::FromIterator;
|
||||
use core::ops::{Sub, BitOr, BitAnd, BitXor};
|
||||
|
||||
// FIXME(contentions): implement union family of methods? (general design may be wrong here)
|
||||
|
||||
|
@ -14,14 +14,16 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use core::cmp::Ordering;
|
||||
use core::default::Default;
|
||||
use core::fmt;
|
||||
use core::iter;
|
||||
use core::raw::Slice as RawSlice;
|
||||
use core::ptr;
|
||||
use core::iter::{mod, FromIterator, RandomAccessIterator};
|
||||
use core::kinds::marker;
|
||||
use core::mem;
|
||||
use core::num::{Int, UnsignedInt};
|
||||
use core::ops::{Index, IndexMut};
|
||||
use core::ptr;
|
||||
use core::raw::Slice as RawSlice;
|
||||
|
||||
use std::hash::{Writer, Hash};
|
||||
use std::cmp;
|
||||
|
@ -89,15 +89,19 @@
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use core::borrow::{BorrowFrom, BorrowFromMut, ToOwned};
|
||||
use core::cmp;
|
||||
use core::iter::{range_step, MultiplicativeIterator};
|
||||
use core::clone::Clone;
|
||||
use core::cmp::Ordering::{mod, Greater, Less};
|
||||
use core::cmp::{mod, Ord};
|
||||
use core::iter::{Iterator, IteratorExt, IteratorCloneExt};
|
||||
use core::iter::{range, range_step, MultiplicativeIterator};
|
||||
use core::kinds::Sized;
|
||||
use core::mem::size_of;
|
||||
use core::mem;
|
||||
use core::ops::{FnMut,SliceMut};
|
||||
use core::prelude::{Clone, Greater, Iterator, IteratorExt, Less, None, Option};
|
||||
use core::prelude::{Ord, Ordering, PtrExt, Some, range, IteratorCloneExt, Result};
|
||||
use core::ops::{FnMut, SliceMut};
|
||||
use core::option::Option::{mod, Some, None};
|
||||
use core::ptr::PtrExt;
|
||||
use core::ptr;
|
||||
use core::result::Result;
|
||||
use core::slice as core_slice;
|
||||
use self::Direction::*;
|
||||
|
||||
|
@ -17,12 +17,14 @@
|
||||
use core::prelude::*;
|
||||
|
||||
use core::borrow::{Cow, IntoCow};
|
||||
use core::cmp::Equiv;
|
||||
use core::default::Default;
|
||||
use core::fmt;
|
||||
use core::hash;
|
||||
use core::iter::FromIterator;
|
||||
use core::mem;
|
||||
use core::ops::{mod, Deref, Add};
|
||||
use core::ptr;
|
||||
use core::ops;
|
||||
use core::raw::Slice as RawSlice;
|
||||
use unicode::str as unicode_str;
|
||||
use unicode::str::Utf16Item;
|
||||
|
@ -50,14 +50,16 @@ use alloc::boxed::Box;
|
||||
use alloc::heap::{EMPTY, allocate, reallocate, deallocate};
|
||||
use core::borrow::{Cow, IntoCow};
|
||||
use core::cmp::max;
|
||||
use core::cmp::{Equiv, Ordering};
|
||||
use core::default::Default;
|
||||
use core::fmt;
|
||||
use core::hash::{mod, Hash};
|
||||
use core::iter::repeat;
|
||||
use core::iter::{repeat, FromIterator};
|
||||
use core::kinds::marker::{ContravariantLifetime, InvariantType};
|
||||
use core::mem;
|
||||
use core::nonzero::NonZero;
|
||||
use core::num::{Int, UnsignedInt};
|
||||
use core::ops::{Index, IndexMut, Deref, Add};
|
||||
use core::ops;
|
||||
use core::ptr;
|
||||
use core::raw::Slice as RawSlice;
|
||||
|
@ -15,12 +15,14 @@
|
||||
|
||||
use core::prelude::*;
|
||||
|
||||
use core::cmp::Ordering;
|
||||
use core::default::Default;
|
||||
use core::fmt;
|
||||
use core::hash::{Hash, Writer};
|
||||
use core::iter::{Enumerate, FilterMap, Map, FromIterator};
|
||||
use core::iter;
|
||||
use core::iter::{Enumerate, FilterMap, Map};
|
||||
use core::mem::replace;
|
||||
use core::ops::{Index, IndexMut};
|
||||
|
||||
use {vec, slice};
|
||||
use vec::Vec;
|
||||
|
@ -125,11 +125,12 @@ impl Ordering {
|
||||
/// # Example
|
||||
///
|
||||
/// ```rust
|
||||
/// use std::cmp::Ordering::{Less, Equal, Greater};
|
||||
///
|
||||
/// assert_eq!(Less.reverse(), Greater);
|
||||
/// assert_eq!(Equal.reverse(), Equal);
|
||||
/// assert_eq!(Greater.reverse(), Less);
|
||||
///
|
||||
///
|
||||
/// let mut data: &mut [_] = &mut [2u, 10, 5, 8];
|
||||
///
|
||||
/// // sort the array from largest to smallest.
|
||||
@ -170,6 +171,8 @@ pub trait Ord for Sized?: Eq + PartialOrd<Self> {
|
||||
/// the expression `self <operator> other` if true. For example:
|
||||
///
|
||||
/// ```
|
||||
/// use std::cmp::Ordering::{Less, Equal, Greater};
|
||||
///
|
||||
/// assert_eq!( 5u.cmp(&10), Less); // because 5 < 10
|
||||
/// assert_eq!(10u.cmp(&5), Greater); // because 10 > 5
|
||||
/// assert_eq!( 5u.cmp(&5), Equal); // because 5 == 5
|
||||
|
@ -25,6 +25,8 @@
|
||||
//! demonstrates adding and subtracting two `Point`s.
|
||||
//!
|
||||
//! ```rust
|
||||
//! use std::ops::{Add, Sub};
|
||||
//!
|
||||
//! #[deriving(Show)]
|
||||
//! struct Point {
|
||||
//! x: int,
|
||||
@ -68,13 +70,13 @@ use option::Option::{mod, Some, None};
|
||||
/// struct HasDrop;
|
||||
///
|
||||
/// impl Drop for HasDrop {
|
||||
/// fn drop(&mut self) {
|
||||
/// println!("Dropping!");
|
||||
/// }
|
||||
/// fn drop(&mut self) {
|
||||
/// println!("Dropping!");
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// let _x = HasDrop;
|
||||
/// let _x = HasDrop;
|
||||
/// }
|
||||
/// ```
|
||||
#[lang="drop"]
|
||||
@ -91,6 +93,8 @@ pub trait Drop {
|
||||
/// calling `add`, and therefore, `main` prints `Adding!`.
|
||||
///
|
||||
/// ```rust
|
||||
/// use std::ops::Add;
|
||||
///
|
||||
/// #[deriving(Copy)]
|
||||
/// struct Foo;
|
||||
///
|
||||
@ -130,6 +134,8 @@ add_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
|
||||
/// calling `sub`, and therefore, `main` prints `Subtracting!`.
|
||||
///
|
||||
/// ```rust
|
||||
/// use std::ops::Sub;
|
||||
///
|
||||
/// #[deriving(Copy)]
|
||||
/// struct Foo;
|
||||
///
|
||||
@ -169,6 +175,8 @@ sub_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
|
||||
/// calling `mul`, and therefore, `main` prints `Multiplying!`.
|
||||
///
|
||||
/// ```rust
|
||||
/// use std::ops::Mul;
|
||||
///
|
||||
/// #[deriving(Copy)]
|
||||
/// struct Foo;
|
||||
///
|
||||
@ -208,6 +216,8 @@ mul_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
|
||||
/// calling `div`, and therefore, `main` prints `Dividing!`.
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::Div;
|
||||
///
|
||||
/// #[deriving(Copy)]
|
||||
/// struct Foo;
|
||||
///
|
||||
@ -247,6 +257,8 @@ div_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 }
|
||||
/// calling `rem`, and therefore, `main` prints `Remainder-ing!`.
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::Rem;
|
||||
///
|
||||
/// #[deriving(Copy)]
|
||||
/// struct Foo;
|
||||
///
|
||||
@ -300,6 +312,8 @@ rem_float_impl! { f64, fmod }
|
||||
/// `neg`, and therefore, `main` prints `Negating!`.
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::Neg;
|
||||
///
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
@ -356,6 +370,8 @@ neg_uint_impl! { u64, i64 }
|
||||
/// `not`, and therefore, `main` prints `Not-ing!`.
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::Not;
|
||||
///
|
||||
/// struct Foo;
|
||||
///
|
||||
/// impl Copy for Foo {}
|
||||
@ -396,6 +412,8 @@ not_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// calling `bitand`, and therefore, `main` prints `Bitwise And-ing!`.
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::BitAnd;
|
||||
///
|
||||
/// #[deriving(Copy)]
|
||||
/// struct Foo;
|
||||
///
|
||||
@ -435,6 +453,8 @@ bitand_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// calling `bitor`, and therefore, `main` prints `Bitwise Or-ing!`.
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::BitOr;
|
||||
///
|
||||
/// #[deriving(Copy)]
|
||||
/// struct Foo;
|
||||
///
|
||||
@ -474,6 +494,8 @@ bitor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// calling `bitxor`, and therefore, `main` prints `Bitwise Xor-ing!`.
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::BitXor;
|
||||
///
|
||||
/// #[deriving(Copy)]
|
||||
/// struct Foo;
|
||||
///
|
||||
@ -513,6 +535,8 @@ bitxor_impl! { bool uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// calling `shl`, and therefore, `main` prints `Shifting left!`.
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::Shl;
|
||||
///
|
||||
/// #[deriving(Copy)]
|
||||
/// struct Foo;
|
||||
///
|
||||
@ -554,6 +578,8 @@ shl_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// calling `shr`, and therefore, `main` prints `Shifting right!`.
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::Shr;
|
||||
///
|
||||
/// #[deriving(Copy)]
|
||||
/// struct Foo;
|
||||
///
|
||||
@ -594,6 +620,8 @@ shr_impl! { uint u8 u16 u32 u64 int i8 i16 i32 i64 }
|
||||
/// calling `index`, and therefore, `main` prints `Indexing!`.
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::Index;
|
||||
///
|
||||
/// #[deriving(Copy)]
|
||||
/// struct Foo;
|
||||
///
|
||||
@ -623,6 +651,8 @@ pub trait Index<Sized? Index, Sized? Result> for Sized? {
|
||||
/// calling `index_mut`, and therefore, `main` prints `Indexing!`.
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::IndexMut;
|
||||
///
|
||||
/// #[deriving(Copy)]
|
||||
/// struct Foo;
|
||||
///
|
||||
@ -652,6 +682,8 @@ pub trait IndexMut<Sized? Index, Sized? Result> for Sized? {
|
||||
/// calling `slice_to`, and therefore, `main` prints `Slicing!`.
|
||||
///
|
||||
/// ```ignore
|
||||
/// use std::ops::Slice;
|
||||
///
|
||||
/// #[deriving(Copy)]
|
||||
/// struct Foo;
|
||||
///
|
||||
@ -699,6 +731,8 @@ pub trait Slice<Sized? Idx, Sized? Result> for Sized? {
|
||||
/// calling `slice_from_mut`, and therefore, `main` prints `Slicing!`.
|
||||
///
|
||||
/// ```ignore
|
||||
/// use std::ops::SliceMut;
|
||||
///
|
||||
/// #[deriving(Copy)]
|
||||
/// struct Foo;
|
||||
///
|
||||
@ -827,6 +861,8 @@ pub struct RangeTo<Idx> {
|
||||
/// struct.
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::Deref;
|
||||
///
|
||||
/// struct DerefExample<T> {
|
||||
/// value: T
|
||||
/// }
|
||||
@ -865,6 +901,8 @@ impl<'a, Sized? T> Deref<T> for &'a mut T {
|
||||
/// struct.
|
||||
///
|
||||
/// ```
|
||||
/// use std::ops::{Deref, DerefMut};
|
||||
///
|
||||
/// struct DerefMutExample<T> {
|
||||
/// value: T
|
||||
/// }
|
||||
|
@ -30,39 +30,24 @@
|
||||
|
||||
// Reexported core operators
|
||||
pub use kinds::{Copy, Send, Sized, Sync};
|
||||
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
|
||||
pub use ops::{BitAnd, BitOr, BitXor};
|
||||
pub use ops::{Drop, Deref, DerefMut};
|
||||
pub use ops::{Shl, Shr};
|
||||
pub use ops::{Index, IndexMut};
|
||||
pub use ops::{Slice, SliceMut};
|
||||
pub use ops::{Fn, FnMut, FnOnce};
|
||||
pub use ops::{Drop, Fn, FnMut, FnOnce};
|
||||
|
||||
// Reexported functions
|
||||
pub use iter::range;
|
||||
pub use mem::drop;
|
||||
pub use str::from_str;
|
||||
|
||||
// Reexported types and traits
|
||||
|
||||
pub use char::Char;
|
||||
pub use clone::Clone;
|
||||
pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
|
||||
pub use cmp::{Ordering, Equiv};
|
||||
pub use cmp::Ordering::{Less, Equal, Greater};
|
||||
pub use iter::{FromIterator, Extend, IteratorExt};
|
||||
pub use iter::{Iterator, DoubleEndedIterator, DoubleEndedIteratorExt, RandomAccessIterator};
|
||||
pub use iter::{IteratorCloneExt, CloneIteratorExt, IteratorPairExt};
|
||||
pub use iter::{IteratorOrdExt, MutableDoubleEndedIterator, ExactSizeIterator};
|
||||
pub use num::{ToPrimitive, FromPrimitive};
|
||||
pub use option::Option;
|
||||
pub use option::Option::{Some, None};
|
||||
pub use iter::{Extend, IteratorExt};
|
||||
pub use iter::{Iterator, DoubleEndedIterator, DoubleEndedIteratorExt};
|
||||
pub use iter::{IteratorCloneExt, CloneIteratorExt};
|
||||
pub use iter::{IteratorOrdExt, ExactSizeIterator, IteratorPairExt};
|
||||
pub use option::Option::{mod, Some, None};
|
||||
pub use ptr::{PtrExt, MutPtrExt};
|
||||
pub use result::Result;
|
||||
pub use result::Result::{Ok, Err};
|
||||
pub use str::{Str, StrExt};
|
||||
pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
|
||||
pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
|
||||
pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
|
||||
pub use slice::{PartialEqSliceExt, OrdSliceExt};
|
||||
pub use result::Result::{mod, Ok, Err};
|
||||
pub use slice::{AsSlice, SliceExt};
|
||||
pub use slice::{PartialEqSliceExt, OrdSliceExt};
|
||||
pub use str::{Str, StrExt};
|
||||
|
@ -32,35 +32,6 @@
|
||||
//! * `PartialOrd`
|
||||
//! * `Ord`
|
||||
//! * `Default`
|
||||
//!
|
||||
//! # Examples
|
||||
//!
|
||||
//! Using methods:
|
||||
//!
|
||||
//! ```
|
||||
//! #[allow(deprecated)]
|
||||
//! # fn main() {
|
||||
//! let pair = ("pi", 3.14f64);
|
||||
//! assert_eq!(pair.val0(), "pi");
|
||||
//! assert_eq!(pair.val1(), 3.14f64);
|
||||
//! # }
|
||||
//! ```
|
||||
//!
|
||||
//! Using traits implemented for tuples:
|
||||
//!
|
||||
//! ```
|
||||
//! use std::default::Default;
|
||||
//!
|
||||
//! let a = (1i, 2i);
|
||||
//! let b = (3i, 4i);
|
||||
//! assert!(a != b);
|
||||
//!
|
||||
//! let c = b.clone();
|
||||
//! assert!(b == c);
|
||||
//!
|
||||
//! let d : (u32, f32) = Default::default();
|
||||
//! assert_eq!(d, (0u32, 0.0f32));
|
||||
//! ```
|
||||
|
||||
#![stable]
|
||||
|
||||
|
@ -8,7 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use core::cmp::{ partial_min, partial_max };
|
||||
use core::cmp::{partial_min, partial_max};
|
||||
use core::cmp::Ordering::{Less, Greater, Equal};
|
||||
|
||||
#[test]
|
||||
fn test_int_totalord() {
|
||||
|
@ -17,6 +17,7 @@ mod tests {
|
||||
use core::int;
|
||||
use core::num::{FromStrRadix, Int, SignedInt};
|
||||
use core::str::from_str;
|
||||
use core::ops::{Shl, Shr, Not, BitXor, BitAnd, BitOr};
|
||||
use num;
|
||||
|
||||
#[test]
|
||||
|
@ -13,6 +13,7 @@ use core::fmt::Show;
|
||||
use core::num::{NumCast, cast};
|
||||
use core::ops::{Add, Sub, Mul, Div, Rem};
|
||||
use core::kinds::Copy;
|
||||
use std::str::from_str;
|
||||
|
||||
mod int_macros;
|
||||
mod i8;
|
||||
@ -54,6 +55,7 @@ mod test {
|
||||
use core::option::Option::{Some, None};
|
||||
use core::num::Float;
|
||||
use core::num::from_str_radix;
|
||||
use core::str::from_str;
|
||||
|
||||
#[test]
|
||||
fn from_str_issue7588() {
|
||||
|
@ -16,6 +16,7 @@ mod tests {
|
||||
use core::$T_i::*;
|
||||
use core::num::Int;
|
||||
use num;
|
||||
use core::ops::{BitOr, BitAnd, BitXor, Shl, Shr, Not};
|
||||
|
||||
#[test]
|
||||
fn test_overflows() {
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::str::from_str;
|
||||
|
||||
#[test]
|
||||
fn test_bool_from_str() {
|
||||
assert_eq!(from_str::<bool>("true"), Some(true));
|
||||
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::cmp::Ordering::{Equal, Less, Greater};
|
||||
|
||||
#[test]
|
||||
fn test_clone() {
|
||||
let a = (1i, "2");
|
||||
|
@ -47,6 +47,7 @@
|
||||
//! which is cyclic.
|
||||
//!
|
||||
//! ```rust
|
||||
//! use std::borrow::IntoCow;
|
||||
//! use graphviz as dot;
|
||||
//!
|
||||
//! type Nd = int;
|
||||
@ -146,6 +147,7 @@
|
||||
//! entity `&sube`).
|
||||
//!
|
||||
//! ```rust
|
||||
//! use std::borrow::IntoCow;
|
||||
//! use graphviz as dot;
|
||||
//!
|
||||
//! type Nd = uint;
|
||||
@ -201,6 +203,7 @@
|
||||
//! Hasse-diagram for the subsets of the set `{x, y}`.
|
||||
//!
|
||||
//! ```rust
|
||||
//! use std::borrow::IntoCow;
|
||||
//! use graphviz as dot;
|
||||
//!
|
||||
//! type Nd<'a> = (uint, &'a str);
|
||||
@ -273,6 +276,7 @@
|
||||
|
||||
pub use self::LabelText::*;
|
||||
|
||||
use std::borrow::IntoCow;
|
||||
use std::io;
|
||||
use std::str::CowString;
|
||||
use std::vec::CowVec;
|
||||
@ -586,6 +590,7 @@ mod tests {
|
||||
use super::{Nodes, Edges, GraphWalk, render};
|
||||
use std::io::IoResult;
|
||||
use std::str;
|
||||
use std::borrow::IntoCow;
|
||||
|
||||
/// each node is an index in a vector in the graph.
|
||||
type Node = uint;
|
||||
|
@ -12,8 +12,10 @@
|
||||
|
||||
pub use self::MaybeOwnedVector::*;
|
||||
|
||||
use std::cmp::{Equiv, Ordering};
|
||||
use std::default::Default;
|
||||
use std::fmt;
|
||||
use std::iter::FromIterator;
|
||||
use std::path::BytesContainer;
|
||||
use std::slice;
|
||||
|
||||
@ -125,7 +127,7 @@ impl<'a,T> FromIterator<T> for MaybeOwnedVector<'a,T> {
|
||||
fn from_iter<I:Iterator<T>>(iterator: I) -> MaybeOwnedVector<'a,T> {
|
||||
// If we are building from scratch, might as well build the
|
||||
// most flexible variant.
|
||||
Growable(FromIterator::from_iter(iterator))
|
||||
Growable(iterator.collect())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ impl Rand for ChaChaRng {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::prelude::*;
|
||||
use std::prelude::v1::*;
|
||||
|
||||
use core::iter::order;
|
||||
use {Rng, SeedableRng};
|
||||
|
@ -94,7 +94,7 @@ impl IndependentSample<f64> for Exp {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::prelude::*;
|
||||
use std::prelude::v1::*;
|
||||
|
||||
use distributions::{Sample, IndependentSample};
|
||||
use super::Exp;
|
||||
@ -124,7 +124,7 @@ mod test {
|
||||
mod bench {
|
||||
extern crate test;
|
||||
|
||||
use std::prelude::*;
|
||||
use std::prelude::v1::*;
|
||||
|
||||
use self::test::Bencher;
|
||||
use std::mem::size_of;
|
||||
|
@ -323,7 +323,7 @@ impl IndependentSample<f64> for StudentT {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::prelude::*;
|
||||
use std::prelude::v1::*;
|
||||
|
||||
use distributions::{Sample, IndependentSample};
|
||||
use super::{ChiSquared, StudentT, FisherF};
|
||||
@ -385,7 +385,7 @@ mod test {
|
||||
#[cfg(test)]
|
||||
mod bench {
|
||||
extern crate test;
|
||||
use std::prelude::*;
|
||||
use std::prelude::v1::*;
|
||||
use self::test::Bencher;
|
||||
use std::mem::size_of;
|
||||
use distributions::IndependentSample;
|
||||
|
@ -258,7 +258,7 @@ fn ziggurat<R: Rng, P, Z>(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::prelude::*;
|
||||
use std::prelude::v1::*;
|
||||
|
||||
use {Rng, Rand};
|
||||
use super::{RandSample, WeightedChoice, Weighted, Sample, IndependentSample};
|
||||
|
@ -160,7 +160,7 @@ impl IndependentSample<f64> for LogNormal {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::prelude::*;
|
||||
use std::prelude::v1::*;
|
||||
|
||||
use distributions::{Sample, IndependentSample};
|
||||
use super::{Normal, LogNormal};
|
||||
@ -200,7 +200,7 @@ mod tests {
|
||||
#[cfg(test)]
|
||||
mod bench {
|
||||
extern crate test;
|
||||
use std::prelude::*;
|
||||
use std::prelude::v1::*;
|
||||
use self::test::Bencher;
|
||||
use std::mem::size_of;
|
||||
use distributions::{Sample};
|
||||
|
@ -164,7 +164,7 @@ float_impl! { f64 }
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::num::Int;
|
||||
use std::prelude::*;
|
||||
use std::prelude::v1::*;
|
||||
use distributions::{Sample, IndependentSample};
|
||||
use super::Range;
|
||||
|
||||
|
@ -487,7 +487,7 @@ impl Rand for Isaac64Rng {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::prelude::*;
|
||||
use std::prelude::v1::*;
|
||||
|
||||
use core::iter::order;
|
||||
use {Rng, SeedableRng};
|
||||
|
@ -214,7 +214,7 @@ impl<T:Rand> Rand for Option<T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::prelude::*;
|
||||
use std::prelude::v1::*;
|
||||
use std::rand::{Rng, thread_rng, Open01, Closed01};
|
||||
|
||||
struct ConstantRng(u64);
|
||||
|
@ -149,7 +149,7 @@ impl Default for ReseedWithDefault {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::prelude::*;
|
||||
use std::prelude::v1::*;
|
||||
|
||||
use core::iter::order;
|
||||
use super::{ReseedingRng, ReseedWithDefault};
|
||||
|
@ -11,6 +11,7 @@
|
||||
pub use self::NamesIter::*;
|
||||
pub use self::Regex::*;
|
||||
|
||||
use std::borrow::IntoCow;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::str::CowString;
|
||||
|
@ -37,6 +37,7 @@ pub use self::MatchKind::*;
|
||||
pub use self::StepState::*;
|
||||
|
||||
use std::cmp;
|
||||
use std::cmp::Ordering::{mod, Less, Equal, Greater};
|
||||
use std::mem;
|
||||
use std::iter::repeat;
|
||||
use std::slice::SliceExt;
|
||||
|
@ -36,10 +36,11 @@ use util::ppaux::{ty_to_string};
|
||||
use util::nodemap::{FnvHashMap, NodeSet};
|
||||
use lint::{Context, LintPass, LintArray};
|
||||
|
||||
use std::{cmp, slice};
|
||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
use std::num::SignedInt;
|
||||
use std::{cmp, slice};
|
||||
use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
|
||||
|
||||
use syntax::{abi, ast, ast_map};
|
||||
use syntax::ast_util::is_shift_binop;
|
||||
use syntax::attr::{mod, AttrMetaMethods};
|
||||
|
@ -32,13 +32,15 @@ use middle::ty::{ImplContainer, TraitContainer};
|
||||
use middle::ty::{mod, Ty};
|
||||
use middle::astencode::vtable_decoder_helpers;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::hash::Hash;
|
||||
use std::hash;
|
||||
use std::io::extensions::u64_from_be_bytes;
|
||||
use std::io;
|
||||
use std::collections::hash_map::HashMap;
|
||||
use std::num::FromPrimitive;
|
||||
use std::rc::Rc;
|
||||
use std::str;
|
||||
|
||||
use rbml::reader;
|
||||
use rbml;
|
||||
use serialize::Decodable;
|
||||
|
@ -25,7 +25,6 @@ use middle::ty::{mod, AsPredicate, Ty};
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::str;
|
||||
use std::string::String;
|
||||
use syntax::abi;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
|
@ -11,7 +11,9 @@
|
||||
/// This module provides linkage between rustc::middle::graph and
|
||||
/// libgraphviz traits.
|
||||
|
||||
/// For clarity, rename the graphviz crate locally to dot.
|
||||
use std::borrow::IntoCow;
|
||||
|
||||
// For clarity, rename the graphviz crate locally to dot.
|
||||
use graphviz as dot;
|
||||
|
||||
use syntax::ast;
|
||||
|
@ -24,8 +24,7 @@ use middle::pat_util::*;
|
||||
use middle::ty::*;
|
||||
use middle::ty;
|
||||
use std::fmt;
|
||||
use std::iter::AdditiveIterator;
|
||||
use std::iter::{range_inclusive, repeat};
|
||||
use std::iter::{range_inclusive, AdditiveIterator, FromIterator, repeat};
|
||||
use std::num::Float;
|
||||
use std::slice;
|
||||
use syntax::ast::{mod, DUMMY_NODE_ID, NodeId, Pat};
|
||||
|
@ -27,8 +27,8 @@ use syntax::ptr::P;
|
||||
use syntax::visit::{mod, Visitor};
|
||||
use syntax::{ast_map, ast_util, codemap};
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::collections::hash_map::Entry::Vacant;
|
||||
use std::rc::Rc;
|
||||
|
||||
//
|
||||
// This pass classifies expressions by their constant-ness.
|
||||
|
@ -33,8 +33,9 @@ use util::nodemap::{FnvHashMap, FnvHashSet};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::u32;
|
||||
use std::cmp::Ordering::{mod, Less, Greater, Equal};
|
||||
use std::iter::repeat;
|
||||
use std::u32;
|
||||
use syntax::ast;
|
||||
|
||||
mod doc;
|
||||
|
@ -36,6 +36,7 @@ use syntax::visit::Visitor;
|
||||
use syntax::visit;
|
||||
|
||||
use std::iter::Enumerate;
|
||||
use std::num::FromPrimitive;
|
||||
use std::slice;
|
||||
|
||||
// The actual lang items defined come at the end of this file in one handy table.
|
||||
|
@ -69,7 +69,7 @@ use util::nodemap::{FnvHashMap};
|
||||
use arena::TypedArena;
|
||||
use std::borrow::BorrowFrom;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::cmp;
|
||||
use std::cmp::{mod, Ordering};
|
||||
use std::fmt::{mod, Show};
|
||||
use std::hash::{Hash, sip, Writer};
|
||||
use std::mem;
|
||||
|
@ -394,6 +394,7 @@ macro_rules! cgoptions {
|
||||
|
||||
mod cgsetters {
|
||||
use super::{CodegenOptions, Passes, SomePasses, AllPasses};
|
||||
use std::str::from_str;
|
||||
|
||||
$(
|
||||
pub fn $opt(cg: &mut CodegenOptions, v: Option<&str>) -> bool {
|
||||
|
@ -33,7 +33,7 @@ impl<'tcx> MoveErrorCollector<'tcx> {
|
||||
}
|
||||
|
||||
pub fn report_potential_errors<'a>(&self, bccx: &BorrowckCtxt<'a, 'tcx>) {
|
||||
report_move_errors(bccx, self.errors.borrow().deref())
|
||||
report_move_errors(bccx, &*self.errors.borrow())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ use rustc::middle::cfg::{CFGIndex};
|
||||
use rustc::middle::dataflow::{DataFlowOperator, DataFlowContext, EntryOrExit};
|
||||
use rustc::middle::dataflow;
|
||||
use std::rc::Rc;
|
||||
use std::borrow::IntoCow;
|
||||
|
||||
#[deriving(Show, Copy)]
|
||||
pub enum Variant {
|
||||
|
@ -54,6 +54,8 @@ use rustc::metadata;
|
||||
use rustc::DIAGNOSTICS;
|
||||
|
||||
use std::any::AnyRefExt;
|
||||
use std::cmp::Ordering::Equal;
|
||||
use std::comm::channel;
|
||||
use std::io;
|
||||
use std::iter::repeat;
|
||||
use std::os;
|
||||
|
@ -13,8 +13,9 @@
|
||||
use libc;
|
||||
use ArchiveRef;
|
||||
|
||||
use std::raw;
|
||||
use std::c_str::ToCStr;
|
||||
use std::mem;
|
||||
use std::raw;
|
||||
|
||||
pub struct ArchiveRO {
|
||||
ptr: ArchiveRef,
|
||||
|
@ -61,8 +61,9 @@ use syntax::parse::token::{mod, special_idents};
|
||||
use syntax::codemap::{Span, DUMMY_SP};
|
||||
use syntax::visit::{mod, Visitor};
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::mem::replace;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::rc::Rc;
|
||||
|
||||
// Specifies how duplicates should be handled when adding a child item if
|
||||
// another item exists with the same name in some namespace.
|
||||
|
@ -17,6 +17,8 @@
|
||||
// `use` directives.
|
||||
//
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
use Resolver;
|
||||
use Namespace::{TypeNS, ValueNS};
|
||||
|
||||
|
@ -27,6 +27,7 @@ use rustc::middle::def::Export;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::rc::Rc;
|
||||
|
||||
struct ExportRecorder<'a, 'b:'a, 'tcx:'b> {
|
||||
|
@ -20,6 +20,7 @@ use rustc::util::common::time;
|
||||
use libc;
|
||||
use flate;
|
||||
|
||||
use std::c_str::ToCStr;
|
||||
use std::iter;
|
||||
use std::mem;
|
||||
use std::num::Int;
|
||||
|
@ -23,6 +23,7 @@ use syntax::diagnostic;
|
||||
use syntax::diagnostic::{Emitter, Handler, Level, mk_handler};
|
||||
|
||||
use std::c_str::{ToCStr, CString};
|
||||
use std::comm::channel;
|
||||
use std::io::Command;
|
||||
use std::io::fs;
|
||||
use std::iter::Unfold;
|
||||
|
@ -1202,8 +1202,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
||||
let glob_map = &self.analysis.glob_map;
|
||||
let glob_map = glob_map.as_ref().unwrap();
|
||||
if glob_map.contains_key(&id) {
|
||||
let names = glob_map.index(&id);
|
||||
for n in names.iter() {
|
||||
for n in glob_map[id].iter() {
|
||||
if name_string.len() > 0 {
|
||||
name_string.push_str(", ");
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ use trans::machine::llalign_of_pref;
|
||||
use trans::type_::Type;
|
||||
use util::nodemap::FnvHashMap;
|
||||
use libc::{c_uint, c_char};
|
||||
use std::string::String;
|
||||
use std::c_str::ToCStr;
|
||||
use syntax::codemap::Span;
|
||||
|
||||
pub struct Builder<'a, 'tcx: 'a> {
|
||||
|
@ -26,6 +26,7 @@ use trans::type_of;
|
||||
use middle::ty::{mod, Ty};
|
||||
use middle::subst::{Substs};
|
||||
use std::cmp;
|
||||
use std::c_str::ToCStr;
|
||||
use libc::c_uint;
|
||||
use syntax::abi::{Cdecl, Aapcs, C, Win64, Abi};
|
||||
use syntax::abi::{RustIntrinsic, Rust, RustCall, Stdcall, Fastcall, System};
|
||||
|
@ -18,10 +18,10 @@
|
||||
|
||||
pub use self::imp::Lock;
|
||||
|
||||
|
||||
#[cfg(unix)]
|
||||
mod imp {
|
||||
use libc;
|
||||
use std::c_str::ToCStr;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
mod os {
|
||||
|
@ -29,11 +29,12 @@
|
||||
|
||||
use libc;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::c_str::ToCStr;
|
||||
use std::cell::{RefCell, Cell};
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::slice;
|
||||
use std::str;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use html::toc::TocBuilder;
|
||||
use html::highlight;
|
||||
|
@ -35,6 +35,7 @@
|
||||
pub use self::ExternalLocation::*;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::cmp::Ordering::{mod, Less, Greater, Equal};
|
||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::default::Default;
|
||||
|
@ -13,8 +13,9 @@
|
||||
//! hierarchy, with item counts for every stability level per module. A parent
|
||||
//! module's count includes its children's.
|
||||
|
||||
use std::ops::Add;
|
||||
use std::cmp::Ordering;
|
||||
use std::num::Zero;
|
||||
use std::ops::Add;
|
||||
|
||||
use syntax::attr::{Deprecated, Experimental, Unstable, Stable, Frozen, Locked};
|
||||
use syntax::ast::Public;
|
||||
|
@ -9,14 +9,14 @@
|
||||
// except according to those terms.
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::comm::channel;
|
||||
use std::dynamic_lib::DynamicLibrary;
|
||||
use std::io::{Command, TempDir};
|
||||
use std::io;
|
||||
use std::os;
|
||||
use std::str;
|
||||
use std::string::String;
|
||||
use std::thunk::Thunk;
|
||||
use std::thread::Thread;
|
||||
use std::thunk::Thunk;
|
||||
|
||||
use std::collections::{HashSet, HashMap};
|
||||
use testing;
|
||||
|
@ -315,8 +315,8 @@ static ASCII_UPPERCASE_MAP: [u8; 256] = [
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use prelude::v1::*;
|
||||
use super::*;
|
||||
use prelude::*;
|
||||
use char::from_u32;
|
||||
|
||||
#[test]
|
||||
|
@ -209,7 +209,7 @@ macro_rules! bitflags {
|
||||
}
|
||||
}
|
||||
|
||||
impl BitOr<$BitFlags, $BitFlags> for $BitFlags {
|
||||
impl ::std::ops::BitOr<$BitFlags, $BitFlags> for $BitFlags {
|
||||
/// Returns the union of the two sets of flags.
|
||||
#[inline]
|
||||
fn bitor(self, other: $BitFlags) -> $BitFlags {
|
||||
@ -217,7 +217,7 @@ macro_rules! bitflags {
|
||||
}
|
||||
}
|
||||
|
||||
impl BitXor<$BitFlags, $BitFlags> for $BitFlags {
|
||||
impl ::std::ops::BitXor<$BitFlags, $BitFlags> for $BitFlags {
|
||||
/// Returns the left flags, but with all the right flags toggled.
|
||||
#[inline]
|
||||
fn bitxor(self, other: $BitFlags) -> $BitFlags {
|
||||
@ -225,7 +225,7 @@ macro_rules! bitflags {
|
||||
}
|
||||
}
|
||||
|
||||
impl BitAnd<$BitFlags, $BitFlags> for $BitFlags {
|
||||
impl ::std::ops::BitAnd<$BitFlags, $BitFlags> for $BitFlags {
|
||||
/// Returns the intersection between the two sets of flags.
|
||||
#[inline]
|
||||
fn bitand(self, other: $BitFlags) -> $BitFlags {
|
||||
@ -233,7 +233,7 @@ macro_rules! bitflags {
|
||||
}
|
||||
}
|
||||
|
||||
impl Sub<$BitFlags, $BitFlags> for $BitFlags {
|
||||
impl ::std::ops::Sub<$BitFlags, $BitFlags> for $BitFlags {
|
||||
/// Returns the set difference of the two sets of flags.
|
||||
#[inline]
|
||||
fn sub(self, other: $BitFlags) -> $BitFlags {
|
||||
@ -241,7 +241,7 @@ macro_rules! bitflags {
|
||||
}
|
||||
}
|
||||
|
||||
impl Not<$BitFlags> for $BitFlags {
|
||||
impl ::std::ops::Not<$BitFlags> for $BitFlags {
|
||||
/// Returns the complement of this set of flags.
|
||||
#[inline]
|
||||
fn not(self) -> $BitFlags {
|
||||
|
@ -45,6 +45,8 @@
|
||||
//! ```rust
|
||||
//! extern crate libc;
|
||||
//!
|
||||
//! use std::c_str::ToCStr;
|
||||
//!
|
||||
//! extern {
|
||||
//! fn puts(s: *const libc::c_char);
|
||||
//! }
|
||||
@ -70,6 +72,7 @@
|
||||
use core::prelude::*;
|
||||
use libc;
|
||||
|
||||
use cmp::Ordering;
|
||||
use fmt;
|
||||
use hash;
|
||||
use mem;
|
||||
@ -155,6 +158,8 @@ impl CString {
|
||||
/// one).
|
||||
///
|
||||
/// ```rust
|
||||
/// use std::c_str::ToCStr;
|
||||
///
|
||||
/// let foo = "some string";
|
||||
///
|
||||
/// // right
|
||||
@ -170,6 +175,8 @@ impl CString {
|
||||
/// ```rust
|
||||
/// extern crate libc;
|
||||
///
|
||||
/// use std::c_str::ToCStr;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let c_str = "foo bar".to_c_str();
|
||||
/// unsafe {
|
||||
@ -189,6 +196,8 @@ impl CString {
|
||||
/// one).
|
||||
///
|
||||
/// ```rust
|
||||
/// use std::c_str::ToCStr;
|
||||
///
|
||||
/// let foo = "some string";
|
||||
///
|
||||
/// // right
|
||||
@ -309,6 +318,8 @@ pub trait ToCStr for Sized? {
|
||||
/// ```rust
|
||||
/// extern crate libc;
|
||||
///
|
||||
/// use std::c_str::ToCStr;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let s = "PATH".with_c_str(|path| unsafe {
|
||||
/// libc::getenv(path)
|
||||
@ -539,8 +550,7 @@ pub unsafe fn from_c_multistring<F>(buf: *const libc::c_char,
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use prelude::{spawn, Some, None, Option, FnOnce, ToString, CloneSliceExt};
|
||||
use prelude::{Clone, PtrExt, Iterator, SliceExt, StrExt};
|
||||
use prelude::v1::*;
|
||||
use ptr;
|
||||
use thread::Thread;
|
||||
use libc;
|
||||
@ -732,9 +742,10 @@ mod tests {
|
||||
mod bench {
|
||||
extern crate test;
|
||||
|
||||
use prelude::v1::*;
|
||||
use self::test::Bencher;
|
||||
use libc;
|
||||
use prelude::*;
|
||||
use c_str::ToCStr;
|
||||
|
||||
#[inline]
|
||||
fn check(s: &str, c_str: *const libc::c_char) {
|
||||
|
@ -172,7 +172,7 @@ impl<T> AsSlice<T> for CVec<T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
|
||||
use super::CVec;
|
||||
use libc;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#![cfg(test)]
|
||||
|
||||
extern crate test;
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
|
||||
use self::test::Bencher;
|
||||
use iter::{range_inclusive};
|
||||
|
@ -87,7 +87,7 @@ impl DefaultResizePolicy {
|
||||
|
||||
#[test]
|
||||
fn test_resize_policy() {
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
let rp = DefaultResizePolicy;
|
||||
for n in range(0u, 1000) {
|
||||
assert!(rp.min_capacity(rp.usable_capacity(n)) <= n);
|
||||
@ -1530,8 +1530,9 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> Extend<(K, V)> for HashMap<K
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_map {
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
|
||||
use cmp::Equiv;
|
||||
use super::HashMap;
|
||||
use super::Entry::{Occupied, Vacant};
|
||||
use hash;
|
||||
|
@ -866,7 +866,7 @@ impl<'a, T, S, H> Iterator<&'a T> for Union<'a, T, H>
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_set {
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
|
||||
use super::HashSet;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -153,11 +153,12 @@ impl<T: Send> Drop for Queue<T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use prelude::*;
|
||||
|
||||
use alloc::arc::Arc;
|
||||
use prelude::v1::*;
|
||||
|
||||
use comm::channel;
|
||||
use super::{Queue, Data, Empty, Inconsistent};
|
||||
use sync::Arc;
|
||||
use thread::Thread;
|
||||
|
||||
#[test]
|
||||
fn test_full() {
|
||||
@ -181,12 +182,12 @@ mod tests {
|
||||
for _ in range(0, nthreads) {
|
||||
let tx = tx.clone();
|
||||
let q = q.clone();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
for i in range(0, nmsgs) {
|
||||
q.push(i);
|
||||
}
|
||||
tx.send(());
|
||||
});
|
||||
}).detach();
|
||||
}
|
||||
|
||||
let mut i = 0u;
|
||||
|
@ -27,6 +27,8 @@
|
||||
//! # Example
|
||||
//!
|
||||
//! ```rust
|
||||
//! use std::comm::channel;
|
||||
//!
|
||||
//! let (tx1, rx1) = channel();
|
||||
//! let (tx2, rx2) = channel();
|
||||
//!
|
||||
@ -335,9 +337,10 @@ impl Iterator<*mut Handle<'static, ()>> for Packets {
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
mod test {
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
|
||||
use super::*;
|
||||
use comm::*;
|
||||
use thread::Thread;
|
||||
|
||||
// Don't use the libstd version so we can pull in the right Select structure
|
||||
// (std::comm points at the wrong one)
|
||||
@ -357,7 +360,8 @@ mod test {
|
||||
})
|
||||
}
|
||||
|
||||
test! { fn smoke() {
|
||||
#[test]
|
||||
fn smoke() {
|
||||
let (tx1, rx1) = channel::<int>();
|
||||
let (tx2, rx2) = channel::<int>();
|
||||
tx1.send(1);
|
||||
@ -379,9 +383,10 @@ mod test {
|
||||
select! {
|
||||
bar = rx2.recv_opt() => { assert_eq!(bar, Err(())); }
|
||||
}
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn smoke2() {
|
||||
#[test]
|
||||
fn smoke2() {
|
||||
let (_tx1, rx1) = channel::<int>();
|
||||
let (_tx2, rx2) = channel::<int>();
|
||||
let (_tx3, rx3) = channel::<int>();
|
||||
@ -395,9 +400,10 @@ mod test {
|
||||
_foo = rx4.recv() => { panic!("4") },
|
||||
foo = rx5.recv() => { assert_eq!(foo, 4); }
|
||||
}
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn closed() {
|
||||
#[test]
|
||||
fn closed() {
|
||||
let (_tx1, rx1) = channel::<int>();
|
||||
let (tx2, rx2) = channel::<int>();
|
||||
drop(tx2);
|
||||
@ -406,14 +412,15 @@ mod test {
|
||||
_a1 = rx1.recv_opt() => { panic!() },
|
||||
a2 = rx2.recv_opt() => { assert_eq!(a2, Err(())); }
|
||||
}
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn unblocks() {
|
||||
#[test]
|
||||
fn unblocks() {
|
||||
let (tx1, rx1) = channel::<int>();
|
||||
let (_tx2, rx2) = channel::<int>();
|
||||
let (tx3, rx3) = channel::<int>();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
for _ in range(0u, 20) { Thread::yield_now(); }
|
||||
tx1.send(1);
|
||||
rx3.recv();
|
||||
@ -429,14 +436,15 @@ mod test {
|
||||
a = rx1.recv_opt() => { assert_eq!(a, Err(())); },
|
||||
_b = rx2.recv() => { panic!() }
|
||||
}
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn both_ready() {
|
||||
#[test]
|
||||
fn both_ready() {
|
||||
let (tx1, rx1) = channel::<int>();
|
||||
let (tx2, rx2) = channel::<int>();
|
||||
let (tx3, rx3) = channel::<()>();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
for _ in range(0u, 20) { Thread::yield_now(); }
|
||||
tx1.send(1);
|
||||
tx2.send(2);
|
||||
@ -454,15 +462,16 @@ mod test {
|
||||
assert_eq!(rx1.try_recv(), Err(Empty));
|
||||
assert_eq!(rx2.try_recv(), Err(Empty));
|
||||
tx3.send(());
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn stress() {
|
||||
#[test]
|
||||
fn stress() {
|
||||
static AMT: int = 10000;
|
||||
let (tx1, rx1) = channel::<int>();
|
||||
let (tx2, rx2) = channel::<int>();
|
||||
let (tx3, rx3) = channel::<()>();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
for i in range(0, AMT) {
|
||||
if i % 2 == 0 {
|
||||
tx1.send(i);
|
||||
@ -480,14 +489,15 @@ mod test {
|
||||
}
|
||||
tx3.send(());
|
||||
}
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn cloning() {
|
||||
#[test]
|
||||
fn cloning() {
|
||||
let (tx1, rx1) = channel::<int>();
|
||||
let (_tx2, rx2) = channel::<int>();
|
||||
let (tx3, rx3) = channel::<()>();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
rx3.recv();
|
||||
tx1.clone();
|
||||
assert_eq!(rx3.try_recv(), Err(Empty));
|
||||
@ -501,14 +511,15 @@ mod test {
|
||||
_i2 = rx2.recv() => panic!()
|
||||
}
|
||||
tx3.send(());
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn cloning2() {
|
||||
#[test]
|
||||
fn cloning2() {
|
||||
let (tx1, rx1) = channel::<int>();
|
||||
let (_tx2, rx2) = channel::<int>();
|
||||
let (tx3, rx3) = channel::<()>();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
rx3.recv();
|
||||
tx1.clone();
|
||||
assert_eq!(rx3.try_recv(), Err(Empty));
|
||||
@ -522,13 +533,14 @@ mod test {
|
||||
_i2 = rx2.recv() => panic!()
|
||||
}
|
||||
tx3.send(());
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn cloning3() {
|
||||
#[test]
|
||||
fn cloning3() {
|
||||
let (tx1, rx1) = channel::<()>();
|
||||
let (tx2, rx2) = channel::<()>();
|
||||
let (tx3, rx3) = channel::<()>();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let s = Select::new();
|
||||
let mut h1 = s.handle(&rx1);
|
||||
let mut h2 = s.handle(&rx2);
|
||||
@ -542,44 +554,49 @@ mod test {
|
||||
drop(tx1.clone());
|
||||
tx2.send(());
|
||||
rx3.recv();
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn preflight1() {
|
||||
#[test]
|
||||
fn preflight1() {
|
||||
let (tx, rx) = channel();
|
||||
tx.send(());
|
||||
select! {
|
||||
() = rx.recv() => {}
|
||||
}
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn preflight2() {
|
||||
#[test]
|
||||
fn preflight2() {
|
||||
let (tx, rx) = channel();
|
||||
tx.send(());
|
||||
tx.send(());
|
||||
select! {
|
||||
() = rx.recv() => {}
|
||||
}
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn preflight3() {
|
||||
#[test]
|
||||
fn preflight3() {
|
||||
let (tx, rx) = channel();
|
||||
drop(tx.clone());
|
||||
tx.send(());
|
||||
select! {
|
||||
() = rx.recv() => {}
|
||||
}
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn preflight4() {
|
||||
#[test]
|
||||
fn preflight4() {
|
||||
let (tx, rx) = channel();
|
||||
tx.send(());
|
||||
let s = Select::new();
|
||||
let mut h = s.handle(&rx);
|
||||
unsafe { h.add(); }
|
||||
assert_eq!(s.wait2(false), h.id);
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn preflight5() {
|
||||
#[test]
|
||||
fn preflight5() {
|
||||
let (tx, rx) = channel();
|
||||
tx.send(());
|
||||
tx.send(());
|
||||
@ -587,9 +604,10 @@ mod test {
|
||||
let mut h = s.handle(&rx);
|
||||
unsafe { h.add(); }
|
||||
assert_eq!(s.wait2(false), h.id);
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn preflight6() {
|
||||
#[test]
|
||||
fn preflight6() {
|
||||
let (tx, rx) = channel();
|
||||
drop(tx.clone());
|
||||
tx.send(());
|
||||
@ -597,18 +615,20 @@ mod test {
|
||||
let mut h = s.handle(&rx);
|
||||
unsafe { h.add(); }
|
||||
assert_eq!(s.wait2(false), h.id);
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn preflight7() {
|
||||
#[test]
|
||||
fn preflight7() {
|
||||
let (tx, rx) = channel::<()>();
|
||||
drop(tx);
|
||||
let s = Select::new();
|
||||
let mut h = s.handle(&rx);
|
||||
unsafe { h.add(); }
|
||||
assert_eq!(s.wait2(false), h.id);
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn preflight8() {
|
||||
#[test]
|
||||
fn preflight8() {
|
||||
let (tx, rx) = channel();
|
||||
tx.send(());
|
||||
drop(tx);
|
||||
@ -617,9 +637,10 @@ mod test {
|
||||
let mut h = s.handle(&rx);
|
||||
unsafe { h.add(); }
|
||||
assert_eq!(s.wait2(false), h.id);
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn preflight9() {
|
||||
#[test]
|
||||
fn preflight9() {
|
||||
let (tx, rx) = channel();
|
||||
drop(tx.clone());
|
||||
tx.send(());
|
||||
@ -629,12 +650,13 @@ mod test {
|
||||
let mut h = s.handle(&rx);
|
||||
unsafe { h.add(); }
|
||||
assert_eq!(s.wait2(false), h.id);
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn oneshot_data_waiting() {
|
||||
#[test]
|
||||
fn oneshot_data_waiting() {
|
||||
let (tx1, rx1) = channel();
|
||||
let (tx2, rx2) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
select! {
|
||||
() = rx1.recv() => {}
|
||||
}
|
||||
@ -644,16 +666,17 @@ mod test {
|
||||
for _ in range(0u, 100) { Thread::yield_now() }
|
||||
tx1.send(());
|
||||
rx2.recv();
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn stream_data_waiting() {
|
||||
#[test]
|
||||
fn stream_data_waiting() {
|
||||
let (tx1, rx1) = channel();
|
||||
let (tx2, rx2) = channel();
|
||||
tx1.send(());
|
||||
tx1.send(());
|
||||
rx1.recv();
|
||||
rx1.recv();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
select! {
|
||||
() = rx1.recv() => {}
|
||||
}
|
||||
@ -663,15 +686,16 @@ mod test {
|
||||
for _ in range(0u, 100) { Thread::yield_now() }
|
||||
tx1.send(());
|
||||
rx2.recv();
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn shared_data_waiting() {
|
||||
#[test]
|
||||
fn shared_data_waiting() {
|
||||
let (tx1, rx1) = channel();
|
||||
let (tx2, rx2) = channel();
|
||||
drop(tx1.clone());
|
||||
tx1.send(());
|
||||
rx1.recv();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
select! {
|
||||
() = rx1.recv() => {}
|
||||
}
|
||||
@ -681,32 +705,35 @@ mod test {
|
||||
for _ in range(0u, 100) { Thread::yield_now() }
|
||||
tx1.send(());
|
||||
rx2.recv();
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn sync1() {
|
||||
#[test]
|
||||
fn sync1() {
|
||||
let (tx, rx) = sync_channel::<int>(1);
|
||||
tx.send(1);
|
||||
select! {
|
||||
n = rx.recv() => { assert_eq!(n, 1); }
|
||||
}
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn sync2() {
|
||||
#[test]
|
||||
fn sync2() {
|
||||
let (tx, rx) = sync_channel::<int>(0);
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
for _ in range(0u, 100) { Thread::yield_now() }
|
||||
tx.send(1);
|
||||
});
|
||||
select! {
|
||||
n = rx.recv() => { assert_eq!(n, 1); }
|
||||
}
|
||||
} }
|
||||
}
|
||||
|
||||
test! { fn sync3() {
|
||||
#[test]
|
||||
fn sync3() {
|
||||
let (tx1, rx1) = sync_channel::<int>(0);
|
||||
let (tx2, rx2): (Sender<int>, Receiver<int>) = channel();
|
||||
spawn(move|| { tx1.send(1); });
|
||||
spawn(move|| { tx2.send(2); });
|
||||
let _t = Thread::spawn(move|| { tx1.send(1); });
|
||||
let _t = Thread::spawn(move|| { tx2.send(2); });
|
||||
select! {
|
||||
n = rx1.recv() => {
|
||||
assert_eq!(n, 1);
|
||||
@ -717,5 +744,5 @@ mod test {
|
||||
assert_eq!(rx1.recv(), 1);
|
||||
}
|
||||
}
|
||||
} }
|
||||
}
|
||||
}
|
||||
|
@ -240,10 +240,12 @@ impl<T: Send> Drop for Queue<T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
|
||||
use sync::Arc;
|
||||
use super::Queue;
|
||||
use thread::Thread;
|
||||
use comm::channel;
|
||||
|
||||
#[test]
|
||||
fn smoke() {
|
||||
@ -320,7 +322,7 @@ mod test {
|
||||
|
||||
let (tx, rx) = channel();
|
||||
let q2 = q.clone();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
for _ in range(0u, 100000) {
|
||||
loop {
|
||||
match q2.pop() {
|
||||
|
@ -15,7 +15,9 @@
|
||||
#![experimental]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
|
||||
use c_str::ToCStr;
|
||||
use mem;
|
||||
use os;
|
||||
use str;
|
||||
@ -146,7 +148,7 @@ impl DynamicLibrary {
|
||||
#[cfg(all(test, not(target_os = "ios")))]
|
||||
mod test {
|
||||
use super::*;
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
use libc;
|
||||
use mem;
|
||||
|
||||
@ -202,8 +204,8 @@ mod test {
|
||||
pub mod dl {
|
||||
use self::Rtld::*;
|
||||
|
||||
use prelude::*;
|
||||
use c_str::CString;
|
||||
use prelude::v1::*;
|
||||
use c_str::{CString, ToCStr};
|
||||
use libc;
|
||||
use ptr;
|
||||
|
||||
|
@ -78,7 +78,7 @@
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
|
||||
use str::Utf8Error;
|
||||
use string::{FromUtf8Error, FromUtf16Error};
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#![experimental]
|
||||
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
|
||||
use any::{Any, AnyRefExt};
|
||||
use cell::RefCell;
|
||||
|
@ -410,7 +410,7 @@ impl<S: Stream> Writer for BufferedStream<S> {
|
||||
mod test {
|
||||
extern crate test;
|
||||
use io;
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
use super::*;
|
||||
use super::super::{IoResult, EndOfFile};
|
||||
use super::super::mem::MemReader;
|
||||
|
@ -23,6 +23,7 @@ use vec::Vec;
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use std::comm::channel;
|
||||
/// use std::io::ChanReader;
|
||||
///
|
||||
/// let (tx, rx) = channel();
|
||||
@ -114,6 +115,7 @@ impl Reader for ChanReader {
|
||||
///
|
||||
/// ```
|
||||
/// # #![allow(unused_must_use)]
|
||||
/// use std::comm::channel;
|
||||
/// use std::io::ChanWriter;
|
||||
///
|
||||
/// let (tx, rx) = channel();
|
||||
@ -154,7 +156,9 @@ impl Writer for ChanWriter {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
|
||||
use comm::channel;
|
||||
use super::*;
|
||||
use io;
|
||||
use thread::Thread;
|
||||
|
@ -175,7 +175,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
use io;
|
||||
use io::{MemReader, BytesReader};
|
||||
|
||||
@ -507,7 +507,7 @@ mod test {
|
||||
mod bench {
|
||||
extern crate test;
|
||||
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
use self::test::Bencher;
|
||||
|
||||
// why is this a macro? wouldn't an inlined function work just as well?
|
||||
|
@ -819,7 +819,7 @@ fn access_string(access: FileAccess) -> &'static str {
|
||||
#[allow(unused_variables)]
|
||||
#[allow(unused_mut)]
|
||||
mod test {
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
use io::{SeekSet, SeekCur, SeekEnd, Read, Open, ReadWrite, FileType};
|
||||
use io;
|
||||
use str;
|
||||
|
@ -399,9 +399,10 @@ impl<'a> Buffer for BufReader<'a> {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
extern crate "test" as test_crate;
|
||||
use prelude::v1::*;
|
||||
|
||||
use super::*;
|
||||
use io::{SeekSet, SeekCur, SeekEnd, Reader, Writer, Seek};
|
||||
use prelude::{Ok, Err, range, Vec, Buffer, AsSlice, SliceExt, IteratorExt, CloneSliceExt};
|
||||
use io::{SeekSet, SeekCur, SeekEnd};
|
||||
use io;
|
||||
use self::test_crate::Bencher;
|
||||
|
||||
|
@ -233,7 +233,7 @@ use fmt;
|
||||
use int;
|
||||
use iter::{Iterator, IteratorExt};
|
||||
use mem::transmute;
|
||||
use ops::{BitOr, BitXor, BitAnd, Sub, Not, FnOnce};
|
||||
use ops::FnOnce;
|
||||
use option::Option;
|
||||
use option::Option::{Some, None};
|
||||
use os;
|
||||
@ -1918,8 +1918,8 @@ impl fmt::Show for FilePermission {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use self::BadReaderBehavior::*;
|
||||
use super::{IoResult, Reader, MemReader, NoProgress, InvalidInput, Writer};
|
||||
use prelude::{Ok, Vec, Buffer, CloneSliceExt};
|
||||
use super::{IoResult, MemReader, NoProgress, InvalidInput};
|
||||
use prelude::v1::*;
|
||||
use uint;
|
||||
|
||||
#[deriving(Clone, PartialEq, Show)]
|
||||
|
@ -112,7 +112,7 @@ fn lookup(hostname: Option<&str>, servname: Option<&str>, hint: Option<Hint>)
|
||||
// permission without help of apk
|
||||
#[cfg(all(test, not(target_os = "android")))]
|
||||
mod test {
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
use super::*;
|
||||
use io::net::ip::*;
|
||||
|
||||
|
@ -544,7 +544,7 @@ impl<'a> ToSocketAddr for &'a str {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
use super::*;
|
||||
use str::FromStr;
|
||||
|
||||
|
@ -20,14 +20,14 @@
|
||||
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
|
||||
use c_str::ToCStr;
|
||||
use io::{Listener, Acceptor, IoResult, TimedOut, standard_error};
|
||||
use time::Duration;
|
||||
|
||||
use sys::pipe::UnixStream as UnixStreamImp;
|
||||
use sys::pipe::UnixListener as UnixListenerImp;
|
||||
use sys::pipe::UnixAcceptor as UnixAcceptorImp;
|
||||
use sys::pipe::UnixListener as UnixListenerImp;
|
||||
use sys::pipe::UnixStream as UnixStreamImp;
|
||||
use time::Duration;
|
||||
|
||||
use sys_common;
|
||||
|
||||
@ -264,13 +264,17 @@ impl sys_common::AsInner<UnixAcceptorImp> for UnixAcceptor {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(experimental)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use io::*;
|
||||
use io::test::*;
|
||||
use prelude::{Ok, Err, spawn, range, drop, Some, None, channel, Send, FnOnce, Clone};
|
||||
use prelude::v1::*;
|
||||
|
||||
use comm::channel;
|
||||
use io::fs::PathExtensions;
|
||||
use io::{EndOfFile, TimedOut, ShortWrite, IoError, ConnectionReset};
|
||||
use io::{NotConnected, BrokenPipe, OtherIoError, FileNotFound, InvalidInput};
|
||||
use io::{PermissionDenied, Acceptor, Listener};
|
||||
use io::test::*;
|
||||
use super::*;
|
||||
use thread::Thread;
|
||||
use time::Duration;
|
||||
|
||||
pub fn smalltest<F,G>(server: F, client: G)
|
||||
@ -282,7 +286,7 @@ mod tests {
|
||||
|
||||
let mut acceptor = UnixListener::bind(&path1).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
match UnixStream::connect(&path2) {
|
||||
Ok(c) => client(c),
|
||||
Err(e) => panic!("failed connect: {}", e),
|
||||
@ -377,7 +381,7 @@ mod tests {
|
||||
Err(e) => panic!("failed listen: {}", e),
|
||||
};
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
for _ in range(0u, times) {
|
||||
let mut stream = UnixStream::connect(&path2);
|
||||
match stream.write(&[100]) {
|
||||
@ -411,7 +415,7 @@ mod tests {
|
||||
let addr = next_test_unix();
|
||||
let mut acceptor = UnixListener::bind(&addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut s = UnixStream::connect(&addr);
|
||||
let mut buf = [0, 0];
|
||||
debug!("client reading");
|
||||
@ -427,7 +431,7 @@ mod tests {
|
||||
|
||||
let (tx1, rx1) = channel();
|
||||
let (tx2, rx2) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut s2 = s2;
|
||||
rx1.recv();
|
||||
debug!("writer writing");
|
||||
@ -450,7 +454,7 @@ mod tests {
|
||||
let (tx1, rx) = channel();
|
||||
let tx2 = tx1.clone();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut s = UnixStream::connect(&addr);
|
||||
s.write(&[1]).unwrap();
|
||||
rx.recv();
|
||||
@ -462,7 +466,7 @@ mod tests {
|
||||
let s2 = s1.clone();
|
||||
|
||||
let (done, rx) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut s2 = s2;
|
||||
let mut buf = [0, 0];
|
||||
s2.read(&mut buf).unwrap();
|
||||
@ -481,7 +485,7 @@ mod tests {
|
||||
let addr = next_test_unix();
|
||||
let mut acceptor = UnixListener::bind(&addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut s = UnixStream::connect(&addr);
|
||||
let buf = &mut [0, 1];
|
||||
s.read(buf).unwrap();
|
||||
@ -492,7 +496,7 @@ mod tests {
|
||||
let s2 = s1.clone();
|
||||
|
||||
let (tx, rx) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut s2 = s2;
|
||||
s2.write(&[1]).unwrap();
|
||||
tx.send(());
|
||||
@ -539,7 +543,7 @@ mod tests {
|
||||
// continue to receive any pending connections.
|
||||
let (tx, rx) = channel();
|
||||
let addr2 = addr.clone();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
tx.send(UnixStream::connect(&addr2).unwrap());
|
||||
});
|
||||
let l = rx.recv();
|
||||
@ -557,7 +561,7 @@ mod tests {
|
||||
// Unset the timeout and make sure that this always blocks.
|
||||
a.set_timeout(None);
|
||||
let addr2 = addr.clone();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
drop(UnixStream::connect(&addr2).unwrap());
|
||||
});
|
||||
a.accept().unwrap();
|
||||
@ -595,11 +599,11 @@ mod tests {
|
||||
let addr = next_test_unix();
|
||||
let a = UnixListener::bind(&addr).listen().unwrap();
|
||||
let (_tx, rx) = channel::<()>();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let mut a = a;
|
||||
let _s = a.accept().unwrap();
|
||||
let _ = rx.recv_opt();
|
||||
});
|
||||
}).detach();
|
||||
|
||||
let mut b = [0];
|
||||
let mut s = UnixStream::connect(&addr).unwrap();
|
||||
@ -632,16 +636,16 @@ mod tests {
|
||||
let addr = next_test_unix();
|
||||
let a = UnixListener::bind(&addr).listen().unwrap();
|
||||
let (_tx, rx) = channel::<()>();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let mut a = a;
|
||||
let _s = a.accept().unwrap();
|
||||
let _ = rx.recv_opt();
|
||||
});
|
||||
}).detach();
|
||||
|
||||
let mut s = UnixStream::connect(&addr).unwrap();
|
||||
let s2 = s.clone();
|
||||
let (tx, rx) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut s2 = s2;
|
||||
assert!(s2.read(&mut [0]).is_err());
|
||||
tx.send(());
|
||||
@ -658,12 +662,12 @@ mod tests {
|
||||
let addr = next_test_unix();
|
||||
let mut a = UnixListener::bind(&addr).listen().unwrap();
|
||||
let (tx, rx) = channel::<()>();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let mut s = UnixStream::connect(&addr).unwrap();
|
||||
rx.recv();
|
||||
assert!(s.write(&[0]).is_ok());
|
||||
let _ = rx.recv_opt();
|
||||
});
|
||||
}).detach();
|
||||
|
||||
let mut s = a.accept().unwrap();
|
||||
s.set_timeout(Some(20));
|
||||
@ -696,7 +700,7 @@ mod tests {
|
||||
let addr = next_test_unix();
|
||||
let mut a = UnixListener::bind(&addr).listen().unwrap();
|
||||
let (tx, rx) = channel::<()>();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let mut s = UnixStream::connect(&addr).unwrap();
|
||||
rx.recv();
|
||||
let mut amt = 0;
|
||||
@ -707,7 +711,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
let _ = rx.recv_opt();
|
||||
});
|
||||
}).detach();
|
||||
|
||||
let mut s = a.accept().unwrap();
|
||||
s.set_read_timeout(Some(20));
|
||||
@ -725,12 +729,12 @@ mod tests {
|
||||
let addr = next_test_unix();
|
||||
let mut a = UnixListener::bind(&addr).listen().unwrap();
|
||||
let (tx, rx) = channel::<()>();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let mut s = UnixStream::connect(&addr).unwrap();
|
||||
rx.recv();
|
||||
assert!(s.write(&[0]).is_ok());
|
||||
let _ = rx.recv_opt();
|
||||
});
|
||||
}).detach();
|
||||
|
||||
let mut s = a.accept().unwrap();
|
||||
s.set_write_timeout(Some(20));
|
||||
@ -752,17 +756,17 @@ mod tests {
|
||||
let addr = next_test_unix();
|
||||
let mut a = UnixListener::bind(&addr).listen().unwrap();
|
||||
let (tx, rx) = channel::<()>();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let mut s = UnixStream::connect(&addr).unwrap();
|
||||
rx.recv();
|
||||
assert!(s.write(&[0]).is_ok());
|
||||
let _ = rx.recv_opt();
|
||||
});
|
||||
}).detach();
|
||||
|
||||
let mut s = a.accept().unwrap();
|
||||
let s2 = s.clone();
|
||||
let (tx2, rx2) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut s2 = s2;
|
||||
assert!(s2.read(&mut [0]).is_ok());
|
||||
tx2.send(());
|
||||
@ -784,10 +788,10 @@ mod tests {
|
||||
let mut a2 = a.clone();
|
||||
|
||||
let addr2 = addr.clone();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _ = UnixStream::connect(&addr2);
|
||||
});
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _ = UnixStream::connect(&addr);
|
||||
});
|
||||
|
||||
@ -807,14 +811,14 @@ mod tests {
|
||||
let (tx, rx) = channel();
|
||||
let tx2 = tx.clone();
|
||||
|
||||
spawn(move|| { let mut a = a; tx.send(a.accept()) });
|
||||
spawn(move|| { let mut a = a2; tx2.send(a.accept()) });
|
||||
let _t = Thread::spawn(move|| { let mut a = a; tx.send(a.accept()) });
|
||||
let _t = Thread::spawn(move|| { let mut a = a2; tx2.send(a.accept()) });
|
||||
|
||||
let addr2 = addr.clone();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _ = UnixStream::connect(&addr2);
|
||||
});
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _ = UnixStream::connect(&addr);
|
||||
});
|
||||
|
||||
@ -840,7 +844,7 @@ mod tests {
|
||||
let mut a2 = a.clone();
|
||||
|
||||
let (tx, rx) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut a = a;
|
||||
tx.send(a.accept());
|
||||
});
|
||||
|
@ -141,7 +141,7 @@ impl TcpStream {
|
||||
/// let mut stream = TcpStream::connect("127.0.0.1:34254").unwrap();
|
||||
/// let stream2 = stream.clone();
|
||||
///
|
||||
/// Thread::spawn(move|| {
|
||||
/// let _t = Thread::spawn(move|| {
|
||||
/// // close this stream after one second
|
||||
/// timer::sleep(Duration::seconds(1));
|
||||
/// let mut stream = stream2;
|
||||
@ -282,10 +282,10 @@ impl sys_common::AsInner<TcpStreamImp> for TcpStream {
|
||||
/// use std::io::{Acceptor, Listener};
|
||||
/// use std::thread::Thread;
|
||||
///
|
||||
/// let listener = TcpListener::bind("127.0.0.1:80");
|
||||
/// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
|
||||
///
|
||||
/// // bind the listener to the specified address
|
||||
/// let mut acceptor = listener.listen();
|
||||
/// let mut acceptor = listener.listen().unwrap();
|
||||
///
|
||||
/// fn handle_client(mut stream: TcpStream) {
|
||||
/// // ...
|
||||
@ -423,7 +423,7 @@ impl TcpAcceptor {
|
||||
/// let mut a = TcpListener::bind("127.0.0.1:8482").listen().unwrap();
|
||||
/// let a2 = a.clone();
|
||||
///
|
||||
/// Thread::spawn(move|| {
|
||||
/// let _t = Thread::spawn(move|| {
|
||||
/// let mut a2 = a2;
|
||||
/// for socket in a2.incoming() {
|
||||
/// match socket {
|
||||
@ -482,14 +482,16 @@ impl sys_common::AsInner<TcpAcceptorImp> for TcpAcceptor {
|
||||
#[cfg(test)]
|
||||
#[allow(experimental)]
|
||||
mod test {
|
||||
use prelude::v1::*;
|
||||
|
||||
use comm::channel;
|
||||
use thread::Thread;
|
||||
use io::net::tcp::*;
|
||||
use io::net::ip::*;
|
||||
use io::{EndOfFile, TimedOut, IoError, ShortWrite, OtherIoError, ConnectionAborted};
|
||||
use io::{ConnectionRefused, ConnectionReset, BrokenPipe, NotConnected};
|
||||
use io::{PermissionDenied, Listener, Acceptor};
|
||||
use io::test::*;
|
||||
use prelude::{Ok, Err, spawn, range, drop, Some, None, channel, Clone};
|
||||
use prelude::{Reader, Writer, IteratorExt};
|
||||
|
||||
// FIXME #11530 this fails on android because tests are run as root
|
||||
#[cfg_attr(any(windows, target_os = "android"), ignore)]
|
||||
@ -515,7 +517,7 @@ mod test {
|
||||
let listener = TcpListener::bind(socket_addr);
|
||||
let mut acceptor = listener.listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut stream = TcpStream::connect(("localhost", socket_addr.port));
|
||||
stream.write(&[144]).unwrap();
|
||||
});
|
||||
@ -531,7 +533,7 @@ mod test {
|
||||
let addr = next_test_ip4();
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut stream = TcpStream::connect(("localhost", addr.port));
|
||||
stream.write(&[64]).unwrap();
|
||||
});
|
||||
@ -547,7 +549,7 @@ mod test {
|
||||
let addr = next_test_ip4();
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut stream = TcpStream::connect(("127.0.0.1", addr.port));
|
||||
stream.write(&[44]).unwrap();
|
||||
});
|
||||
@ -563,7 +565,7 @@ mod test {
|
||||
let addr = next_test_ip6();
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut stream = TcpStream::connect(("::1", addr.port));
|
||||
stream.write(&[66]).unwrap();
|
||||
});
|
||||
@ -579,7 +581,7 @@ mod test {
|
||||
let addr = next_test_ip4();
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut stream = TcpStream::connect(addr);
|
||||
stream.write(&[99]).unwrap();
|
||||
});
|
||||
@ -595,7 +597,7 @@ mod test {
|
||||
let addr = next_test_ip6();
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut stream = TcpStream::connect(addr);
|
||||
stream.write(&[99]).unwrap();
|
||||
});
|
||||
@ -611,7 +613,7 @@ mod test {
|
||||
let addr = next_test_ip4();
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _stream = TcpStream::connect(addr);
|
||||
// Close
|
||||
});
|
||||
@ -627,7 +629,7 @@ mod test {
|
||||
let addr = next_test_ip6();
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _stream = TcpStream::connect(addr);
|
||||
// Close
|
||||
});
|
||||
@ -643,7 +645,7 @@ mod test {
|
||||
let addr = next_test_ip4();
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _stream = TcpStream::connect(addr);
|
||||
// Close
|
||||
});
|
||||
@ -667,7 +669,7 @@ mod test {
|
||||
let addr = next_test_ip6();
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _stream = TcpStream::connect(addr);
|
||||
// Close
|
||||
});
|
||||
@ -692,7 +694,7 @@ mod test {
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
let (tx, rx) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
drop(TcpStream::connect(addr));
|
||||
tx.send(());
|
||||
});
|
||||
@ -717,7 +719,7 @@ mod test {
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
let (tx, rx) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
drop(TcpStream::connect(addr));
|
||||
tx.send(());
|
||||
});
|
||||
@ -742,7 +744,7 @@ mod test {
|
||||
let max = 10u;
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
for _ in range(0, max) {
|
||||
let mut stream = TcpStream::connect(addr);
|
||||
stream.write(&[99]).unwrap();
|
||||
@ -762,7 +764,7 @@ mod test {
|
||||
let max = 10u;
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
for _ in range(0, max) {
|
||||
let mut stream = TcpStream::connect(addr);
|
||||
stream.write(&[99]).unwrap();
|
||||
@ -782,11 +784,11 @@ mod test {
|
||||
static MAX: int = 10;
|
||||
let acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut acceptor = acceptor;
|
||||
for (i, stream) in acceptor.incoming().enumerate().take(MAX as uint) {
|
||||
// Start another task to handle the connection
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut stream = stream;
|
||||
let mut buf = [0];
|
||||
stream.read(&mut buf).unwrap();
|
||||
@ -801,7 +803,7 @@ mod test {
|
||||
fn connect(i: int, addr: SocketAddr) {
|
||||
if i == MAX { return }
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
debug!("connecting");
|
||||
let mut stream = TcpStream::connect(addr);
|
||||
// Connect again before writing
|
||||
@ -818,11 +820,11 @@ mod test {
|
||||
static MAX: int = 10;
|
||||
let acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut acceptor = acceptor;
|
||||
for (i, stream) in acceptor.incoming().enumerate().take(MAX as uint) {
|
||||
// Start another task to handle the connection
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut stream = stream;
|
||||
let mut buf = [0];
|
||||
stream.read(&mut buf).unwrap();
|
||||
@ -837,7 +839,7 @@ mod test {
|
||||
fn connect(i: int, addr: SocketAddr) {
|
||||
if i == MAX { return }
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
debug!("connecting");
|
||||
let mut stream = TcpStream::connect(addr);
|
||||
// Connect again before writing
|
||||
@ -854,11 +856,11 @@ mod test {
|
||||
let addr = next_test_ip4();
|
||||
let acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut acceptor = acceptor;
|
||||
for stream in acceptor.incoming().take(MAX as uint) {
|
||||
// Start another task to handle the connection
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut stream = stream;
|
||||
let mut buf = [0];
|
||||
stream.read(&mut buf).unwrap();
|
||||
@ -873,7 +875,7 @@ mod test {
|
||||
fn connect(i: int, addr: SocketAddr) {
|
||||
if i == MAX { return }
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
debug!("connecting");
|
||||
let mut stream = TcpStream::connect(addr);
|
||||
// Connect again before writing
|
||||
@ -890,11 +892,11 @@ mod test {
|
||||
let addr = next_test_ip6();
|
||||
let acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut acceptor = acceptor;
|
||||
for stream in acceptor.incoming().take(MAX as uint) {
|
||||
// Start another task to handle the connection
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut stream = stream;
|
||||
let mut buf = [0];
|
||||
stream.read(&mut buf).unwrap();
|
||||
@ -909,7 +911,7 @@ mod test {
|
||||
fn connect(i: int, addr: SocketAddr) {
|
||||
if i == MAX { return }
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
debug!("connecting");
|
||||
let mut stream = TcpStream::connect(addr);
|
||||
// Connect again before writing
|
||||
@ -932,7 +934,7 @@ mod test {
|
||||
|
||||
pub fn peer_name(addr: SocketAddr) {
|
||||
let acceptor = TcpListener::bind(addr).listen();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut acceptor = acceptor;
|
||||
acceptor.accept().unwrap();
|
||||
});
|
||||
@ -967,7 +969,7 @@ mod test {
|
||||
fn partial_read() {
|
||||
let addr = next_test_ip4();
|
||||
let (tx, rx) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut srv = TcpListener::bind(addr).listen().unwrap();
|
||||
tx.send(());
|
||||
let mut cl = srv.accept().unwrap();
|
||||
@ -1004,7 +1006,7 @@ mod test {
|
||||
let addr = next_test_ip4();
|
||||
let (tx, rx) = channel();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
rx.recv();
|
||||
let _stream = TcpStream::connect(addr).unwrap();
|
||||
// Close
|
||||
@ -1029,7 +1031,7 @@ mod test {
|
||||
let addr = next_test_ip4();
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut s = TcpStream::connect(addr);
|
||||
let mut buf = [0, 0];
|
||||
assert_eq!(s.read(&mut buf), Ok(1));
|
||||
@ -1042,7 +1044,7 @@ mod test {
|
||||
|
||||
let (tx1, rx1) = channel();
|
||||
let (tx2, rx2) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut s2 = s2;
|
||||
rx1.recv();
|
||||
s2.write(&[1]).unwrap();
|
||||
@ -1061,7 +1063,7 @@ mod test {
|
||||
let (tx1, rx) = channel();
|
||||
let tx2 = tx1.clone();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut s = TcpStream::connect(addr);
|
||||
s.write(&[1]).unwrap();
|
||||
rx.recv();
|
||||
@ -1073,7 +1075,7 @@ mod test {
|
||||
let s2 = s1.clone();
|
||||
|
||||
let (done, rx) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut s2 = s2;
|
||||
let mut buf = [0, 0];
|
||||
s2.read(&mut buf).unwrap();
|
||||
@ -1092,7 +1094,7 @@ mod test {
|
||||
let addr = next_test_ip4();
|
||||
let mut acceptor = TcpListener::bind(addr).listen();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut s = TcpStream::connect(addr);
|
||||
let mut buf = [0, 1];
|
||||
s.read(&mut buf).unwrap();
|
||||
@ -1103,7 +1105,7 @@ mod test {
|
||||
let s2 = s1.clone();
|
||||
|
||||
let (done, rx) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut s2 = s2;
|
||||
s2.write(&[1]).unwrap();
|
||||
done.send(());
|
||||
@ -1117,7 +1119,7 @@ mod test {
|
||||
fn shutdown_smoke() {
|
||||
let addr = next_test_ip4();
|
||||
let a = TcpListener::bind(addr).unwrap().listen();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut a = a;
|
||||
let mut c = a.accept().unwrap();
|
||||
assert_eq!(c.read_to_end(), Ok(vec!()));
|
||||
@ -1151,7 +1153,7 @@ mod test {
|
||||
// flakiness.
|
||||
if !cfg!(target_os = "freebsd") {
|
||||
let (tx, rx) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
tx.send(TcpStream::connect(addr).unwrap());
|
||||
});
|
||||
let _l = rx.recv();
|
||||
@ -1168,7 +1170,7 @@ mod test {
|
||||
|
||||
// Unset the timeout and make sure that this always blocks.
|
||||
a.set_timeout(None);
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
drop(TcpStream::connect(addr).unwrap());
|
||||
});
|
||||
a.accept().unwrap();
|
||||
@ -1179,11 +1181,11 @@ mod test {
|
||||
let addr = next_test_ip4();
|
||||
let a = TcpListener::bind(addr).listen().unwrap();
|
||||
let (_tx, rx) = channel::<()>();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let mut a = a;
|
||||
let _s = a.accept().unwrap();
|
||||
let _ = rx.recv_opt();
|
||||
});
|
||||
}).detach();
|
||||
|
||||
let mut b = [0];
|
||||
let mut s = TcpStream::connect(addr).unwrap();
|
||||
@ -1216,16 +1218,16 @@ mod test {
|
||||
let addr = next_test_ip4();
|
||||
let a = TcpListener::bind(addr).listen().unwrap();
|
||||
let (_tx, rx) = channel::<()>();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let mut a = a;
|
||||
let _s = a.accept().unwrap();
|
||||
let _ = rx.recv_opt();
|
||||
});
|
||||
}).detach();
|
||||
|
||||
let mut s = TcpStream::connect(addr).unwrap();
|
||||
let s2 = s.clone();
|
||||
let (tx, rx) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut s2 = s2;
|
||||
assert!(s2.read(&mut [0]).is_err());
|
||||
tx.send(());
|
||||
@ -1242,12 +1244,12 @@ mod test {
|
||||
let addr = next_test_ip6();
|
||||
let mut a = TcpListener::bind(addr).listen().unwrap();
|
||||
let (tx, rx) = channel::<()>();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let mut s = TcpStream::connect(addr).unwrap();
|
||||
rx.recv();
|
||||
assert!(s.write(&[0]).is_ok());
|
||||
let _ = rx.recv_opt();
|
||||
});
|
||||
}).detach();
|
||||
|
||||
let mut s = a.accept().unwrap();
|
||||
s.set_timeout(Some(20));
|
||||
@ -1275,7 +1277,7 @@ mod test {
|
||||
let addr = next_test_ip6();
|
||||
let mut a = TcpListener::bind(addr).listen().unwrap();
|
||||
let (tx, rx) = channel::<()>();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let mut s = TcpStream::connect(addr).unwrap();
|
||||
rx.recv();
|
||||
let mut amt = 0;
|
||||
@ -1286,7 +1288,7 @@ mod test {
|
||||
}
|
||||
}
|
||||
let _ = rx.recv_opt();
|
||||
});
|
||||
}).detach();
|
||||
|
||||
let mut s = a.accept().unwrap();
|
||||
s.set_read_timeout(Some(20));
|
||||
@ -1304,12 +1306,12 @@ mod test {
|
||||
let addr = next_test_ip6();
|
||||
let mut a = TcpListener::bind(addr).listen().unwrap();
|
||||
let (tx, rx) = channel::<()>();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let mut s = TcpStream::connect(addr).unwrap();
|
||||
rx.recv();
|
||||
assert!(s.write(&[0]).is_ok());
|
||||
let _ = rx.recv_opt();
|
||||
});
|
||||
}).detach();
|
||||
|
||||
let mut s = a.accept().unwrap();
|
||||
s.set_write_timeout(Some(20));
|
||||
@ -1332,17 +1334,17 @@ mod test {
|
||||
let addr = next_test_ip6();
|
||||
let mut a = TcpListener::bind(addr).listen().unwrap();
|
||||
let (tx, rx) = channel::<()>();
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let mut s = TcpStream::connect(addr).unwrap();
|
||||
rx.recv();
|
||||
assert_eq!(s.write(&[0]), Ok(()));
|
||||
let _ = rx.recv_opt();
|
||||
});
|
||||
}).detach();
|
||||
|
||||
let mut s = a.accept().unwrap();
|
||||
let s2 = s.clone();
|
||||
let (tx2, rx2) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut s2 = s2;
|
||||
assert_eq!(s2.read(&mut [0]), Ok(1));
|
||||
tx2.send(());
|
||||
@ -1365,7 +1367,7 @@ mod test {
|
||||
let (tx, rx) = channel();
|
||||
let (txdone, rxdone) = channel();
|
||||
let txdone2 = txdone.clone();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut tcp = TcpStream::connect(addr).unwrap();
|
||||
rx.recv();
|
||||
tcp.write_u8(0).unwrap();
|
||||
@ -1376,7 +1378,7 @@ mod test {
|
||||
let tcp = accept.accept().unwrap();
|
||||
let tcp2 = tcp.clone();
|
||||
let txdone3 = txdone.clone();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut tcp2 = tcp2;
|
||||
tcp2.read_u8().unwrap();
|
||||
txdone3.send(());
|
||||
@ -1402,10 +1404,10 @@ mod test {
|
||||
let mut a = l.listen().unwrap();
|
||||
let mut a2 = a.clone();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _ = TcpStream::connect(addr);
|
||||
});
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _ = TcpStream::connect(addr);
|
||||
});
|
||||
|
||||
@ -1423,13 +1425,13 @@ mod test {
|
||||
let (tx, rx) = channel();
|
||||
let tx2 = tx.clone();
|
||||
|
||||
spawn(move|| { let mut a = a; tx.send(a.accept()) });
|
||||
spawn(move|| { let mut a = a2; tx2.send(a.accept()) });
|
||||
let _t = Thread::spawn(move|| { let mut a = a; tx.send(a.accept()) });
|
||||
let _t = Thread::spawn(move|| { let mut a = a2; tx2.send(a.accept()) });
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _ = TcpStream::connect(addr);
|
||||
});
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let _ = TcpStream::connect(addr);
|
||||
});
|
||||
|
||||
@ -1455,7 +1457,7 @@ mod test {
|
||||
let mut a2 = a.clone();
|
||||
|
||||
let (tx, rx) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut a = a;
|
||||
tx.send(a.accept());
|
||||
});
|
||||
|
@ -248,11 +248,14 @@ impl Writer for UdpStream {
|
||||
#[cfg(test)]
|
||||
#[allow(experimental)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use prelude::v1::*;
|
||||
|
||||
use comm::channel;
|
||||
use io::net::ip::*;
|
||||
use io::{ShortWrite, IoError, TimedOut, PermissionDenied};
|
||||
use io::{IoError, ShortWrite, TimedOut, PermissionDenied};
|
||||
use io::test::*;
|
||||
use prelude::{Ok, Err, spawn, range, drop, Some, None, channel, Clone, Reader, Writer};
|
||||
use super::*;
|
||||
use thread::Thread;
|
||||
|
||||
// FIXME #11530 this fails on android because tests are run as root
|
||||
#[cfg_attr(any(windows, target_os = "android"), ignore)]
|
||||
@ -272,7 +275,7 @@ mod test {
|
||||
let (tx1, rx1) = channel();
|
||||
let (tx2, rx2) = channel();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
match UdpSocket::bind(client_ip) {
|
||||
Ok(ref mut client) => {
|
||||
rx1.recv();
|
||||
@ -307,7 +310,7 @@ mod test {
|
||||
let client_ip = next_test_ip6();
|
||||
let (tx, rx) = channel::<()>();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
match UdpSocket::bind(client_ip) {
|
||||
Ok(ref mut client) => {
|
||||
rx.recv();
|
||||
@ -343,8 +346,8 @@ mod test {
|
||||
let (tx1, rx1) = channel();
|
||||
let (tx2, rx2) = channel();
|
||||
|
||||
spawn(move|| {
|
||||
let send_as = |&: ip, val: &[u8]| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let send_as = |&:ip, val: &[u8]| {
|
||||
match UdpSocket::bind(ip) {
|
||||
Ok(client) => {
|
||||
let client = box client;
|
||||
@ -387,7 +390,7 @@ mod test {
|
||||
let (tx1, rx1) = channel();
|
||||
let (tx2, rx2) = channel();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
match UdpSocket::bind(client_ip) {
|
||||
Ok(client) => {
|
||||
let client = box client;
|
||||
@ -449,7 +452,7 @@ mod test {
|
||||
let mut sock1 = UdpSocket::bind(addr1).unwrap();
|
||||
let sock2 = UdpSocket::bind(addr2).unwrap();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut sock2 = sock2;
|
||||
let mut buf = [0, 0];
|
||||
assert_eq!(sock2.recv_from(&mut buf), Ok((1, addr1)));
|
||||
@ -461,7 +464,7 @@ mod test {
|
||||
|
||||
let (tx1, rx1) = channel();
|
||||
let (tx2, rx2) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut sock3 = sock3;
|
||||
rx1.recv();
|
||||
sock3.send_to(&[1], addr2).unwrap();
|
||||
@ -482,7 +485,7 @@ mod test {
|
||||
let (tx1, rx) = channel();
|
||||
let tx2 = tx1.clone();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut sock2 = sock2;
|
||||
sock2.send_to(&[1], addr1).unwrap();
|
||||
rx.recv();
|
||||
@ -493,7 +496,7 @@ mod test {
|
||||
let sock3 = sock1.clone();
|
||||
|
||||
let (done, rx) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut sock3 = sock3;
|
||||
let mut buf = [0, 0];
|
||||
sock3.recv_from(&mut buf).unwrap();
|
||||
@ -517,7 +520,7 @@ mod test {
|
||||
let (tx, rx) = channel();
|
||||
let (serv_tx, serv_rx) = channel();
|
||||
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut sock2 = sock2;
|
||||
let mut buf = [0, 1];
|
||||
|
||||
@ -533,7 +536,7 @@ mod test {
|
||||
|
||||
let (done, rx) = channel();
|
||||
let tx2 = tx.clone();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut sock3 = sock3;
|
||||
match sock3.send_to(&[1], addr2) {
|
||||
Ok(..) => { let _ = tx2.send_opt(()); }
|
||||
@ -561,7 +564,7 @@ mod test {
|
||||
|
||||
let (tx, rx) = channel();
|
||||
let (tx2, rx2) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut a = a2;
|
||||
assert_eq!(a.recv_from(&mut [0]), Ok((1, addr1)));
|
||||
assert_eq!(a.send_to(&[0], addr1), Ok(()));
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
|
||||
use io::IoResult;
|
||||
use libc;
|
||||
@ -112,7 +112,10 @@ impl Writer for PipeStream {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
|
||||
use comm::channel;
|
||||
use thread::Thread;
|
||||
|
||||
#[test]
|
||||
fn partial_read() {
|
||||
@ -123,7 +126,7 @@ mod test {
|
||||
let out = PipeStream::open(writer);
|
||||
let mut input = PipeStream::open(reader);
|
||||
let (tx, rx) = channel();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut out = out;
|
||||
out.write(&[10]).unwrap();
|
||||
rx.recv(); // don't close the pipe until the other read has finished
|
||||
|
@ -16,25 +16,25 @@
|
||||
pub use self::StdioContainer::*;
|
||||
pub use self::ProcessExit::*;
|
||||
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
|
||||
use c_str::{CString, ToCStr};
|
||||
use collections::HashMap;
|
||||
use comm::{channel, Receiver};
|
||||
use fmt;
|
||||
use os;
|
||||
use hash::Hash;
|
||||
use io::pipe::{PipeStream, PipePair};
|
||||
use io::{IoResult, IoError};
|
||||
use io;
|
||||
use libc;
|
||||
use c_str::CString;
|
||||
use collections::HashMap;
|
||||
use hash::Hash;
|
||||
#[cfg(windows)]
|
||||
use std::hash::sip::SipState;
|
||||
use io::pipe::{PipeStream, PipePair};
|
||||
use os;
|
||||
use path::BytesContainer;
|
||||
use thread::Thread;
|
||||
|
||||
use sys;
|
||||
use sys::fs::FileDesc;
|
||||
use sys::process::Process as ProcessImp;
|
||||
use sys;
|
||||
use thread::Thread;
|
||||
|
||||
#[cfg(windows)] use std::hash::sip::SipState;
|
||||
|
||||
/// Signal a process to exit, without forcibly killing it. Corresponds to
|
||||
/// SIGTERM on unix platforms.
|
||||
@ -741,18 +741,17 @@ impl Drop for Process {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#![allow(unused_imports)]
|
||||
use prelude::v1::*;
|
||||
|
||||
use super::*;
|
||||
use comm::channel;
|
||||
use io::fs::PathExtensions;
|
||||
use io::timer::*;
|
||||
use io::{Truncate, Write, TimedOut, timer, process, FileNotFound};
|
||||
use prelude::{Ok, Err, spawn, range, drop, Box, Some, None, Option, Vec, Buffer};
|
||||
use prelude::{from_str, Path, String, channel, Reader, Writer, Clone, Slice};
|
||||
use prelude::{SliceExt, Str, StrExt, AsSlice, ToString, GenericPath};
|
||||
use io::fs::PathExtensions;
|
||||
use time::Duration;
|
||||
use str;
|
||||
use rt::running_on_valgrind;
|
||||
use str;
|
||||
use super::*;
|
||||
use thread::Thread;
|
||||
use time::Duration;
|
||||
|
||||
// FIXME(#10380) these tests should not all be ignored on android.
|
||||
|
||||
@ -1156,14 +1155,14 @@ mod tests {
|
||||
fn wait_timeout2() {
|
||||
let (tx, rx) = channel();
|
||||
let tx2 = tx.clone();
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut p = sleeper();
|
||||
p.set_timeout(Some(10));
|
||||
assert_eq!(p.wait().err().unwrap().kind, TimedOut);
|
||||
p.signal_kill().unwrap();
|
||||
tx.send(());
|
||||
});
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
let mut p = sleeper();
|
||||
p.set_timeout(Some(10));
|
||||
assert_eq!(p.wait().err().unwrap().kind, TimedOut);
|
||||
|
@ -78,7 +78,7 @@ impl<T, A: Acceptor<T>> Acceptor<T> for IoResult<A> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
use super::super::mem::*;
|
||||
use io;
|
||||
|
||||
|
@ -520,8 +520,11 @@ impl Writer for StdWriter {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use prelude::v1::*;
|
||||
|
||||
use super::*;
|
||||
use prelude::*;
|
||||
use comm::channel;
|
||||
use thread::Thread;
|
||||
|
||||
#[test]
|
||||
fn smoke() {
|
||||
@ -537,7 +540,7 @@ mod tests {
|
||||
|
||||
let (tx, rx) = channel();
|
||||
let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx));
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move|| {
|
||||
set_stdout(box w);
|
||||
println!("hello!");
|
||||
});
|
||||
@ -550,7 +553,7 @@ mod tests {
|
||||
|
||||
let (tx, rx) = channel();
|
||||
let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx));
|
||||
spawn(move|| {
|
||||
let _t = Thread::spawn(move || -> () {
|
||||
set_stderr(box w);
|
||||
panic!("my special message");
|
||||
});
|
||||
|
@ -12,9 +12,10 @@
|
||||
|
||||
#![macro_escape]
|
||||
|
||||
use prelude::v1::*;
|
||||
|
||||
use libc;
|
||||
use os;
|
||||
use prelude::*;
|
||||
use std::io::net::ip::*;
|
||||
use sync::atomic::{AtomicUint, INIT_ATOMIC_UINT, Relaxed};
|
||||
|
||||
|
@ -225,9 +225,10 @@ fn in_ms_u64(d: Duration) -> u64 {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
|
||||
use super::Timer;
|
||||
use thread::Thread;
|
||||
use time::Duration;
|
||||
|
||||
#[test]
|
||||
@ -357,9 +358,9 @@ mod test {
|
||||
let mut timer = Timer::new().unwrap();
|
||||
let timer_rx = timer.periodic(Duration::milliseconds(1000));
|
||||
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let _ = timer_rx.recv_opt();
|
||||
});
|
||||
}).detach();
|
||||
|
||||
// when we drop the TimerWatcher we're going to destroy the channel,
|
||||
// which must wake up the task on the other end
|
||||
@ -371,9 +372,9 @@ mod test {
|
||||
let mut timer = Timer::new().unwrap();
|
||||
let timer_rx = timer.periodic(Duration::milliseconds(1000));
|
||||
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let _ = timer_rx.recv_opt();
|
||||
});
|
||||
}).detach();
|
||||
|
||||
timer.oneshot(Duration::milliseconds(1));
|
||||
}
|
||||
@ -384,9 +385,9 @@ mod test {
|
||||
let mut timer = Timer::new().unwrap();
|
||||
let timer_rx = timer.periodic(Duration::milliseconds(1000));
|
||||
|
||||
spawn(move|| {
|
||||
Thread::spawn(move|| {
|
||||
let _ = timer_rx.recv_opt();
|
||||
});
|
||||
}).detach();
|
||||
|
||||
timer.sleep(Duration::milliseconds(1));
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
//! Utility implementations of Reader and Writer
|
||||
|
||||
use prelude::*;
|
||||
use prelude::v1::*;
|
||||
use cmp;
|
||||
use io;
|
||||
use slice::bytes::MutableByteVector;
|
||||
@ -278,11 +278,11 @@ impl<T: Iterator<u8>> Reader for IterReader<T> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use prelude::v1::*;
|
||||
|
||||
use io::{MemReader, ByRefReader};
|
||||
use io;
|
||||
use boxed::Box;
|
||||
use super::*;
|
||||
use prelude::{Ok, range, Vec, Buffer, Writer, Reader, ToString, AsSlice};
|
||||
|
||||
#[test]
|
||||
fn test_limit_reader_unlimited() {
|
||||
|
@ -265,6 +265,7 @@ mod std {
|
||||
pub use cell; // used for tls!
|
||||
pub use thread_local; // used for thread_local!
|
||||
pub use kinds; // used for tls!
|
||||
pub use ops; // used for bitflags!
|
||||
|
||||
// The test runner calls ::std::os::args() but really wants realstd
|
||||
#[cfg(test)] pub use realstd::os as os;
|
||||
|
@ -334,6 +334,7 @@ macro_rules! vec {
|
||||
///
|
||||
/// ```
|
||||
/// use std::thread::Thread;
|
||||
/// use std::comm::channel;
|
||||
///
|
||||
/// let (tx1, rx1) = channel();
|
||||
/// let (tx2, rx2) = channel();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user