Add #![feature] attributes to doctests

This commit is contained in:
Brian Anderson 2015-03-13 15:28:35 -07:00
parent df290f127e
commit e9019101a8
107 changed files with 649 additions and 22 deletions

View File

@ -816,8 +816,7 @@ may optionally begin with any number of `attributes` that apply to the
containing module. Attributes on the anonymous crate module define important
metadata that influences the behavior of the compiler.
```{.rust}
# #![allow(unused_attribute)]
```no_run
// Crate name
#![crate_name = "projx"]
@ -1020,6 +1019,7 @@ Use declarations support a number of convenient shortcuts:
An example of `use` declarations:
```
# #![feature(core)]
use std::iter::range_step;
use std::option::Option::{Some, None};
use std::collections::hash_map::{self, HashMap};
@ -1080,6 +1080,7 @@ declarations.
An example of what will and will not work for `use` items:
```
# #![feature(core)]
# #![allow(unused_imports)]
use foo::core::iter; // good: foo is at the root of the crate
use foo::baz::foobaz; // good: foo is at the root of the crate
@ -1781,6 +1782,7 @@ functions, with the exception that they may not have a body and are instead
terminated by a semicolon.
```
# #![feature(libc)]
extern crate libc;
use libc::{c_char, FILE};

View File

@ -88,6 +88,7 @@ When `guard` goes out of scope, it will block execution until the thread is
finished. If we didn't want this behaviour, we could use `thread::spawn()`:
```
# #![feature(old_io, std_misc)]
use std::thread;
use std::old_io::timer;
use std::time::Duration;
@ -146,6 +147,7 @@ As an example, here is a Rust program that would have a data race in many
languages. It will not compile:
```ignore
# #![feature(old_io, std_misc)]
use std::thread;
use std::old_io::timer;
use std::time::Duration;
@ -185,6 +187,7 @@ only one person at a time can mutate what's inside. For that, we can use the
but for a different reason:
```ignore
# #![feature(old_io, std_misc)]
use std::thread;
use std::old_io::timer;
use std::time::Duration;
@ -229,6 +232,7 @@ guard across thread boundaries, which gives us our error.
We can use `Arc<T>` to fix this. Here's the working version:
```
# #![feature(old_io, std_misc)]
use std::sync::{Arc, Mutex};
use std::thread;
use std::old_io::timer;
@ -254,6 +258,7 @@ handle is then moved into the new thread. Let's examine the body of the
thread more closely:
```
# #![feature(old_io, std_misc)]
# use std::sync::{Arc, Mutex};
# use std::thread;
# use std::old_io::timer;

View File

@ -12,6 +12,7 @@ The following is a minimal example of calling a foreign function which will
compile if snappy is installed:
```no_run
# #![feature(libc)]
extern crate libc;
use libc::size_t;
@ -45,6 +46,7 @@ keeping the binding correct at runtime.
The `extern` block can be extended to cover the entire snappy API:
```no_run
# #![feature(libc)]
extern crate libc;
use libc::{c_int, size_t};
@ -80,6 +82,7 @@ length is number of elements currently contained, and the capacity is the total
the allocated memory. The length is less than or equal to the capacity.
```
# #![feature(libc)]
# extern crate libc;
# use libc::{c_int, size_t};
# unsafe fn snappy_validate_compressed_buffer(_: *const u8, _: size_t) -> c_int { 0 }
@ -104,6 +107,7 @@ required capacity to hold the compressed output. The vector can then be passed t
the true length after compression for setting the length.
```
# #![feature(libc)]
# extern crate libc;
# use libc::{size_t, c_int};
# unsafe fn snappy_compress(a: *const u8, b: size_t, c: *mut u8,
@ -130,6 +134,7 @@ Decompression is similar, because snappy stores the uncompressed size as part of
format and `snappy_uncompressed_length` will retrieve the exact buffer size required.
```
# #![feature(libc)]
# extern crate libc;
# use libc::{size_t, c_int};
# unsafe fn snappy_uncompress(compressed: *const u8,
@ -408,6 +413,7 @@ global state. In order to access these variables, you declare them in `extern`
blocks with the `static` keyword:
```no_run
# #![feature(libc)]
extern crate libc;
#[link(name = "readline")]
@ -426,6 +432,7 @@ interface. To do this, statics can be declared with `mut` so we can mutate
them.
```no_run
# #![feature(libc)]
extern crate libc;
use std::ffi::CString;
@ -458,6 +465,7 @@ calling foreign functions. Some foreign functions, most notably the Windows API,
conventions. Rust provides a way to tell the compiler which convention to use:
```
# #![feature(libc)]
extern crate libc;
#[cfg(all(target_os = "win32", target_arch = "x86"))]

View File

@ -246,6 +246,7 @@ These two basic iterators should serve you well. There are some more
advanced iterators, including ones that are infinite. Like `count`:
```rust
# #![feature(core)]
std::iter::count(1, 5);
```
@ -294,6 +295,7 @@ has no side effect on the original iterator. Let's try it out with our infinite
iterator from before, `count()`:
```rust
# #![feature(core)]
for i in std::iter::count(1, 5).take(5) {
println!("{}", i);
}

View File

@ -23,6 +23,7 @@ the ability to use this *method call syntax* via the `impl` keyword.
Here's how it works:
```{rust}
# #![feature(core)]
struct Circle {
x: f64,
y: f64,
@ -87,6 +88,7 @@ original example, `foo.bar().baz()`? This is called 'method chaining', and we
can do it by returning `self`.
```
# #![feature(core)]
struct Circle {
x: f64,
y: f64,
@ -164,6 +166,7 @@ have method overloading, named arguments, or variable arguments. We employ
the builder pattern instead. It looks like this:
```
# #![feature(core)]
struct Circle {
x: f64,
y: f64,

View File

@ -148,6 +148,7 @@ Rust provides iterators for each of these situations:
Usually, the `graphemes()` method on `&str` is what you want:
```
# #![feature(unicode)]
let s = "u͔n͈̰̎i̙̮͚̦c͚̉o̼̩̰͗d͔̆̓ͥé";
for l in s.graphemes(true) {

View File

@ -5,7 +5,7 @@ we haven't seen before. Here's a simple program that reads some input,
and then prints it back out:
```{rust,ignore}
fn main() {
corefn main() {
println!("Type something!");
let input = std::old_io::stdin().read_line().ok().expect("Failed to read line");
@ -28,6 +28,7 @@ Since writing the fully qualified name all the time is annoying, we can use
the `use` statement to import it in:
```{rust}
# #![feature(old_io)]
use std::old_io::stdin;
stdin();
@ -37,6 +38,7 @@ However, it's considered better practice to not import individual functions, but
to import the module, and only use one level of qualification:
```{rust}
# #![feature(old_io)]
use std::old_io;
old_io::stdin();

View File

@ -546,6 +546,8 @@ is an opaque "black box" to the optimizer and so forces it to consider any
argument as used.
```rust
# #![feature(test)]
extern crate test;
# fn main() {

View File

@ -4,6 +4,7 @@ Do you remember the `impl` keyword, used to call a function with method
syntax?
```{rust}
# #![feature(core)]
struct Circle {
x: f64,
y: f64,
@ -21,6 +22,7 @@ Traits are similar, except that we define a trait with just the method
signature, then implement the trait for that struct. Like this:
```{rust}
# #![feature(core)]
struct Circle {
x: f64,
y: f64,
@ -84,6 +86,7 @@ which implements `HasArea` will have an `.area()` method.
Here's an extended example of how this works:
```{rust}
# #![feature(core)]
trait HasArea {
fn area(&self) -> f64;
}
@ -225,6 +228,7 @@ If we add a `use` line right above `main` and make the right things public,
everything is fine:
```{rust}
# #![feature(core)]
use shapes::HasArea;
mod shapes {
@ -408,6 +412,7 @@ but instead, we found a floating-point variable. We need a different bound. `Flo
to the rescue:
```
# #![feature(std_misc)]
use std::num::Float;
fn inverse<T: Float>(x: T) -> Result<T, String> {
@ -423,6 +428,7 @@ from the `Float` trait. Both `f32` and `f64` implement `Float`, so our function
works just fine:
```
# #![feature(std_misc)]
# use std::num::Float;
# fn inverse<T: Float>(x: T) -> Result<T, String> {
# if x == Float::zero() { return Err("x cannot be zero!".to_string()) }

View File

@ -187,6 +187,7 @@ As an example, we give a reimplementation of owned boxes by wrapping
reimplementation is as safe as the `Box` type.
```
# #![feature(libc)]
#![feature(unsafe_destructor)]
extern crate libc;
@ -443,6 +444,7 @@ The function marked `#[start]` is passed the command line parameters
in the same format as C:
```
# #![feature(libc)]
#![feature(lang_items, start, no_std)]
#![no_std]
@ -470,6 +472,7 @@ correct ABI and the correct name, which requires overriding the
compiler's name mangling too:
```ignore
# #![feature(libc)]
#![feature(no_std)]
#![no_std]
#![no_main]
@ -526,6 +529,7 @@ As an example, here is a program that will calculate the dot product of two
vectors provided from C, using idiomatic Rust practices.
```
# #![feature(libc, core)]
#![feature(lang_items, start, no_std)]
#![no_std]
@ -650,6 +654,7 @@ and one for deallocation. A freestanding program that uses the `Box`
sugar for dynamic allocations via `malloc` and `free`:
```
# #![feature(libc)]
#![feature(lang_items, box_syntax, start, no_std)]
#![no_std]

View File

@ -95,6 +95,7 @@ use heap::deallocate;
/// task.
///
/// ```
/// # #![feature(alloc, core)]
/// use std::sync::Arc;
/// use std::thread;
///
@ -185,6 +186,7 @@ impl<T> Arc<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::sync::Arc;
///
/// let five = Arc::new(5);
@ -246,6 +248,7 @@ impl<T> Clone for Arc<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::sync::Arc;
///
/// let five = Arc::new(5);
@ -289,6 +292,7 @@ impl<T: Send + Sync + Clone> Arc<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::sync::Arc;
///
/// let mut five = Arc::new(5);
@ -324,6 +328,7 @@ impl<T: Sync + Send> Drop for Arc<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::sync::Arc;
///
/// {
@ -387,6 +392,7 @@ impl<T: Sync + Send> Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::sync::Arc;
///
/// let five = Arc::new(5);
@ -424,6 +430,7 @@ impl<T: Sync + Send> Clone for Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::sync::Arc;
///
/// let weak_five = Arc::new(5).downgrade();
@ -448,6 +455,7 @@ impl<T: Sync + Send> Drop for Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::sync::Arc;
///
/// {

View File

@ -65,6 +65,7 @@ use core::raw::TraitObject;
/// The following two examples are equivalent:
///
/// ```
/// # #![feature(alloc)]
/// #![feature(box_syntax)]
/// use std::boxed::HEAP;
///
@ -135,6 +136,7 @@ impl<T : ?Sized> Box<T> {
///
/// # Examples
/// ```
/// # #![feature(alloc)]
/// use std::boxed;
///
/// let seventeen = Box::new(17u32);
@ -178,6 +180,7 @@ impl<T: Clone> Clone for Box<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc, core)]
/// let x = Box::new(5);
/// let mut y = Box::new(10);
///

View File

@ -66,6 +66,7 @@
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![doc(test(no_crate_inject))]
#![feature(no_std)]
#![no_std]

View File

@ -32,6 +32,7 @@
//! and have the `Owner` remain allocated as long as any `Gadget` points at it.
//!
//! ```rust
//! # #![feature(alloc, collections)]
//! use std::rc::Rc;
//!
//! struct Owner {
@ -88,6 +89,7 @@
//! Read the `Cell` documentation for more details on interior mutability.
//!
//! ```rust
//! # #![feature(alloc)]
//! use std::rc::Rc;
//! use std::rc::Weak;
//! use std::cell::RefCell;
@ -218,6 +220,7 @@ impl<T> Rc<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::rc::Rc;
///
/// let five = Rc::new(5);
@ -247,6 +250,7 @@ pub fn strong_count<T>(this: &Rc<T>) -> usize { this.strong() }
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::rc;
/// use std::rc::Rc;
///
@ -267,6 +271,7 @@ pub fn is_unique<T>(rc: &Rc<T>) -> bool {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::rc::{self, Rc};
///
/// let x = Rc::new(3);
@ -301,6 +306,7 @@ pub fn try_unwrap<T>(rc: Rc<T>) -> Result<T, Rc<T>> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::rc::{self, Rc};
///
/// let mut x = Rc::new(3);
@ -330,6 +336,7 @@ impl<T: Clone> Rc<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::rc::Rc;
///
/// let mut five = Rc::new(5);
@ -372,6 +379,7 @@ impl<T> Drop for Rc<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::rc::Rc;
///
/// {
@ -420,6 +428,7 @@ impl<T> Clone for Rc<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::rc::Rc;
///
/// let five = Rc::new(5);
@ -648,6 +657,7 @@ impl<T> Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::rc::Rc;
///
/// let five = Rc::new(5);
@ -676,6 +686,7 @@ impl<T> Drop for Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::rc::Rc;
///
/// {
@ -721,6 +732,7 @@ impl<T> Clone for Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(alloc)]
/// use std::rc::Rc;
///
/// let weak_five = Rc::new(5).downgrade();

View File

@ -216,6 +216,7 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from_vec(vec![9, 1, 2, 7, 3, 2]);
/// ```
@ -235,6 +236,7 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]);
///
@ -255,6 +257,7 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]);
///
@ -360,6 +363,7 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::from_vec(vec![1, 3]);
///
@ -405,6 +409,7 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::new();
/// heap.push(1);
@ -436,6 +441,7 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::new();
///
@ -461,6 +467,7 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4, 5, 6, 7]);
/// let vec = heap.into_vec();
@ -478,6 +485,7 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BinaryHeap;
///
/// let mut heap = BinaryHeap::from_vec(vec![1, 2, 4, 5, 7]);

View File

@ -38,6 +38,7 @@
//! [sieve]: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
//!
//! ```
//! # #![feature(collections, core)]
//! use std::collections::{BitSet, BitVec};
//! use std::num::Float;
//! use std::iter;
@ -134,6 +135,7 @@ static FALSE: bool = false;
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(10, false);
@ -250,6 +252,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
/// let mut bv = BitVec::new();
/// ```
@ -264,6 +267,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(10, false);
@ -304,6 +308,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let bv = BitVec::from_bytes(&[0b10100000, 0b00010010]);
@ -346,6 +351,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let bv = BitVec::from_fn(5, |i| { i % 2 == 0 });
@ -364,6 +370,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let bv = BitVec::from_bytes(&[0b01100000]);
@ -396,6 +403,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(5, false);
@ -420,6 +428,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let before = 0b01100000;
@ -440,6 +449,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let before = 0b01100000;
@ -468,6 +478,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let a = 0b01100100;
@ -498,6 +509,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let a = 0b01100100;
@ -528,6 +540,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let a = 0b01100100;
@ -557,6 +570,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(5, true);
@ -581,6 +595,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let bv = BitVec::from_bytes(&[0b01110100, 0b10010010]);
@ -597,6 +612,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(10, false);
@ -614,6 +630,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(10, false);
@ -635,6 +652,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(3, true);
@ -682,6 +700,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let bv = BitVec::from_bytes(&[0b10100000]);
@ -702,6 +721,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_bytes(&[0b01001011]);
@ -728,6 +748,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(3, false);
@ -758,6 +779,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_elem(3, false);
@ -780,6 +802,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::new();
@ -801,6 +824,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_bytes(&[0b01001011]);
@ -851,6 +875,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::from_bytes(&[0b01001001]);
@ -881,6 +906,7 @@ impl BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitVec;
///
/// let mut bv = BitVec::new();
@ -1091,6 +1117,7 @@ impl<'a> IntoIterator for &'a BitVec {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::{BitSet, BitVec};
///
/// // It's a regular set
@ -1187,6 +1214,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitSet;
///
/// let mut s = BitSet::new();
@ -1203,6 +1231,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitSet;
///
/// let mut s = BitSet::with_capacity(100);
@ -1220,6 +1249,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::{BitVec, BitSet};
///
/// let bv = BitVec::from_bytes(&[0b01100000]);
@ -1249,6 +1279,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitSet;
///
/// let mut s = BitSet::with_capacity(100);
@ -1270,6 +1301,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitSet;
///
/// let mut s = BitSet::new();
@ -1296,6 +1328,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitSet;
///
/// let mut s = BitSet::new();
@ -1316,6 +1349,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitSet;
///
/// let mut s = BitSet::new();
@ -1336,6 +1370,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitSet;
///
/// let mut s = BitSet::new();
@ -1382,6 +1417,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BitSet;
///
/// let mut s = BitSet::new();
@ -1414,6 +1450,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::{BitVec, BitSet};
///
/// let s = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01001010]));
@ -1435,6 +1472,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::{BitVec, BitSet};
///
/// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000]));
@ -1465,6 +1503,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::{BitVec, BitSet};
///
/// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000]));
@ -1495,6 +1534,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::{BitSet, BitVec};
///
/// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000]));
@ -1533,6 +1573,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::{BitSet, BitVec};
///
/// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000]));
@ -1562,6 +1603,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::{BitSet, BitVec};
///
/// let a = 0b01101000;
@ -1585,6 +1627,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::{BitSet, BitVec};
///
/// let a = 0b01101000;
@ -1609,6 +1652,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::{BitSet, BitVec};
///
/// let a = 0b01101000;
@ -1641,6 +1685,7 @@ impl BitSet {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::{BitSet, BitVec};
///
/// let a = 0b01101000;

View File

@ -1269,6 +1269,7 @@ impl<K, V> BTreeMap<K, V> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::BTreeMap;
///
/// let mut a = BTreeMap::new();
@ -1291,6 +1292,7 @@ impl<K, V> BTreeMap<K, V> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::BTreeMap;
///
/// let mut a = BTreeMap::new();
@ -1478,6 +1480,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BTreeMap;
/// use std::collections::Bound::{Included, Unbounded};
///
@ -1504,6 +1507,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BTreeMap;
/// use std::collections::Bound::{Included, Excluded};
///
@ -1529,6 +1533,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BTreeMap;
/// use std::collections::btree_map::Entry;
///

View File

@ -116,6 +116,7 @@ impl<T> BTreeSet<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::BTreeSet;
///
/// let set: BTreeSet<usize> = [1, 2, 3, 4].iter().cloned().collect();
@ -137,6 +138,7 @@ impl<T> BTreeSet<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::BTreeSet;
///
/// let set: BTreeSet<usize> = [1, 2, 3, 4].iter().cloned().collect();
@ -162,6 +164,7 @@ impl<T: Ord> BTreeSet<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::BTreeSet;
/// use std::collections::Bound::{Included, Unbounded};
///
@ -190,6 +193,7 @@ impl<T: Ord> BTreeSet<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::BTreeSet;
///
/// let mut a = BTreeSet::new();
@ -213,6 +217,7 @@ impl<T: Ord> BTreeSet<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::BTreeSet;
///
/// let mut a = BTreeSet::new();
@ -237,6 +242,7 @@ impl<T: Ord> BTreeSet<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::BTreeSet;
///
/// let mut a = BTreeSet::new();
@ -261,6 +267,7 @@ impl<T: Ord> BTreeSet<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::BTreeSet;
///
/// let mut a = BTreeSet::new();
@ -333,6 +340,7 @@ impl<T: Ord> BTreeSet<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::BTreeSet;
///
/// let set: BTreeSet<_> = [1, 2, 3].iter().cloned().collect();
@ -350,6 +358,7 @@ impl<T: Ord> BTreeSet<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::BTreeSet;
///
/// let a: BTreeSet<_> = [1, 2, 3].iter().cloned().collect();
@ -371,6 +380,7 @@ impl<T: Ord> BTreeSet<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::BTreeSet;
///
/// let sup: BTreeSet<_> = [1, 2, 3].iter().cloned().collect();
@ -413,6 +423,7 @@ impl<T: Ord> BTreeSet<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::BTreeSet;
///
/// let sub: BTreeSet<_> = [1, 2].iter().cloned().collect();

View File

@ -174,6 +174,7 @@
//! like:
//!
//! ```
//! # #![feature(core, std_misc)]
//! use std::fmt;
//! use std::f64;
//! use std::num::Float;
@ -261,6 +262,7 @@
//! Example usage is:
//!
//! ```
//! # #![feature(old_io)]
//! # #![allow(unused_must_use)]
//! use std::io::Write;
//! let mut w = Vec::new();
@ -288,6 +290,7 @@
//! off, some example usage is:
//!
//! ```
//! # #![feature(old_io)]
//! use std::fmt;
//! use std::io::{self, Write};
//!

View File

@ -22,6 +22,7 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![doc(test(no_crate_inject))]
#![feature(alloc)]
#![feature(box_syntax)]

View File

@ -235,6 +235,7 @@ impl<T> LinkedList<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::LinkedList;
///
/// let mut a = LinkedList::new();
@ -483,6 +484,7 @@ impl<T> LinkedList<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::LinkedList;
///
/// let mut dl = LinkedList::new();
@ -530,6 +532,7 @@ impl<T> LinkedList<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::LinkedList;
///
/// let mut d = LinkedList::new();
@ -548,6 +551,7 @@ impl<T> LinkedList<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::LinkedList;
///
/// let mut d = LinkedList::new();
@ -573,6 +577,7 @@ impl<T> LinkedList<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::LinkedList;
///
/// let mut d = LinkedList::new();
@ -765,6 +770,7 @@ impl<'a, A> IterMut<'a, A> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::LinkedList;
///
/// let mut list: LinkedList<_> = vec![1, 3, 4].into_iter().collect();
@ -792,6 +798,7 @@ impl<'a, A> IterMut<'a, A> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::LinkedList;
///
/// let mut list: LinkedList<_> = vec![1, 2, 3].into_iter().collect();

View File

@ -14,6 +14,7 @@
//! Slices are a view into a block of memory represented as a pointer and a length.
//!
//! ```rust
//! # #![feature(core)]
//! // slicing a Vec
//! let vec = vec!(1, 2, 3);
//! let int_slice = vec.as_slice();
@ -270,6 +271,7 @@ impl<T> [T] {
/// # Examples
///
/// ```rust
/// # #![feature(collections)]
/// let mut a = [1, 2, 3, 4, 5];
/// let b = vec![6, 7, 8];
/// let num_moved = a.move_from(b, 0, 3);
@ -560,6 +562,7 @@ impl<T> [T] {
/// found; the fourth could match any position in `[1,4]`.
///
/// ```rust
/// # #![feature(core)]
/// let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
/// let s = s.as_slice();
///
@ -842,6 +845,7 @@ impl<T> [T] {
/// # Examples
///
/// ```rust
/// # #![feature(collections)]
/// let v = [1, 2, 3];
/// let mut perms = v.permutations();
///
@ -853,6 +857,7 @@ impl<T> [T] {
/// Iterating through permutations one by one.
///
/// ```rust
/// # #![feature(collections)]
/// let v = [1, 2, 3];
/// let mut perms = v.permutations();
///
@ -874,6 +879,7 @@ impl<T> [T] {
/// # Example
///
/// ```rust
/// # #![feature(collections)]
/// let mut dst = [0, 0, 0];
/// let src = [1, 2];
///
@ -921,6 +927,7 @@ impl<T> [T] {
/// found; the fourth could match any position in `[1,4]`.
///
/// ```rust
/// # #![feature(core)]
/// let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
/// let s = s.as_slice();
///
@ -950,6 +957,7 @@ impl<T> [T] {
/// # Example
///
/// ```rust
/// # #![feature(collections)]
/// let v: &mut [_] = &mut [0, 1, 2];
/// v.next_permutation();
/// let b: &mut [_] = &mut [0, 2, 1];
@ -972,6 +980,7 @@ impl<T> [T] {
/// # Example
///
/// ```rust
/// # #![feature(collections)]
/// let v: &mut [_] = &mut [1, 0, 2];
/// v.prev_permutation();
/// let b: &mut [_] = &mut [0, 2, 1];

View File

@ -548,6 +548,7 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// assert!("hello".contains_char('e'));
///
/// assert!(!"hello".contains_char('z'));
@ -739,6 +740,7 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let v: Vec<(usize, usize)> = "abcXXXabcYYYabc".match_indices("abc").collect();
/// assert_eq!(v, [(0,3), (6,9), (12,15)]);
///
@ -761,6 +763,7 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let v: Vec<&str> = "abcXXXabcYYYabc".split_str("abc").collect();
/// assert_eq!(v, ["", "XXX", "YYY", ""]);
///
@ -869,6 +872,7 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let s = "Löwe 老虎 Léopard";
///
/// assert_eq!(s.slice_chars(0, 4), "Löwe");
@ -1019,6 +1023,7 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(str_char)]
/// let s = "Löwe 老虎 Léopard";
/// assert!(s.is_char_boundary(0));
/// // start of `老`
@ -1055,6 +1060,7 @@ impl str {
/// done by `.chars()` or `.char_indices()`.
///
/// ```
/// # #![feature(str_char, core)]
/// use std::str::CharRange;
///
/// let s = "中华Việt Nam";
@ -1105,6 +1111,7 @@ impl str {
/// done by `.chars().rev()` or `.char_indices()`.
///
/// ```
/// # #![feature(str_char, core)]
/// use std::str::CharRange;
///
/// let s = "中华Việt Nam";
@ -1148,6 +1155,7 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(str_char)]
/// let s = "abπc";
/// assert_eq!(s.char_at(1), 'b');
/// assert_eq!(s.char_at(2), 'π');
@ -1172,6 +1180,7 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(str_char)]
/// let s = "abπc";
/// assert_eq!(s.char_at_reverse(1), 'a');
/// assert_eq!(s.char_at_reverse(2), 'b');
@ -1286,6 +1295,7 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let s = "Löwe 老虎 Léopard";
///
/// assert_eq!(s.find_str("老虎 L"), Some(6));
@ -1307,6 +1317,7 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(str_char)]
/// let s = "Löwe 老虎 Léopard";
/// let (c, s1) = s.slice_shift_char().unwrap();
///
@ -1335,6 +1346,7 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let string = "a\nb\nc";
/// let lines: Vec<&str> = string.lines().collect();
///
@ -1434,6 +1446,7 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(unicode, core)]
/// let gr1 = "a\u{310}e\u{301}o\u{308}\u{332}".graphemes(true).collect::<Vec<&str>>();
/// let b: &[_] = &["a\u{310}", "e\u{301}", "o\u{308}\u{332}"];
///
@ -1456,6 +1469,7 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(unicode, core)]
/// let gr_inds = "a̐éö̲\r\n".grapheme_indices(true).collect::<Vec<(usize, &str)>>();
/// let b: &[_] = &[(0, "a̐"), (3, "é"), (6, "ö̲"), (11, "\r\n")];
///
@ -1475,6 +1489,7 @@ impl str {
/// # Examples
///
/// ```
/// # #![feature(str_words)]
/// let some_words = " Mary had\ta little \n\t lamb";
/// let v: Vec<&str> = some_words.words().collect();
///

View File

@ -90,6 +90,7 @@ impl String {
/// # Examples
///
/// ```
/// # #![feature(collections, core)]
/// let s = String::from_str("hello");
/// assert_eq!(s.as_slice(), "hello");
/// ```
@ -122,6 +123,7 @@ impl String {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::str::Utf8Error;
///
/// let hello_vec = vec![104, 101, 108, 108, 111];
@ -350,6 +352,7 @@ impl String {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let s = String::from_str("hello");
/// let bytes = s.into_bytes();
/// assert_eq!(bytes, [104, 101, 108, 108, 111]);
@ -365,6 +368,7 @@ impl String {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let mut s = String::from_str("foo");
/// s.push_str("bar");
/// assert_eq!(s, "foobar");
@ -441,6 +445,7 @@ impl String {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let mut s = String::from_str("foo");
/// s.reserve(100);
/// assert!(s.capacity() >= 100);
@ -458,6 +463,7 @@ impl String {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let mut s = String::from_str("abc");
/// s.push('1');
/// s.push('2');
@ -493,6 +499,7 @@ impl String {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let s = String::from_str("hello");
/// let b: &[_] = &[104, 101, 108, 108, 111];
/// assert_eq!(s.as_bytes(), b);
@ -513,6 +520,7 @@ impl String {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let mut s = String::from_str("hello");
/// s.truncate(2);
/// assert_eq!(s, "he");
@ -530,6 +538,7 @@ impl String {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let mut s = String::from_str("foo");
/// assert_eq!(s.pop(), Some('o'));
/// assert_eq!(s.pop(), Some('o'));
@ -567,6 +576,7 @@ impl String {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let mut s = String::from_str("foo");
/// assert_eq!(s.remove(0), 'f');
/// assert_eq!(s.remove(1), 'o');
@ -629,6 +639,7 @@ impl String {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let mut s = String::from_str("hello");
/// unsafe {
/// let vec = s.as_mut_vec();
@ -930,6 +941,7 @@ impl<'a> Deref for DerefString<'a> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::string::as_string;
///
/// fn string_consumer(s: String) {

View File

@ -73,6 +73,7 @@ use borrow::{Cow, IntoCow};
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let mut vec = Vec::new();
/// vec.push(1);
/// vec.push(2);
@ -345,6 +346,7 @@ impl<T> Vec<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let mut vec = Vec::with_capacity(10);
/// vec.push_all(&[1, 2, 3]);
/// assert_eq!(vec.capacity(), 10);
@ -400,6 +402,7 @@ impl<T> Vec<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let mut vec = vec![1, 2, 3, 4];
/// vec.truncate(2);
/// assert_eq!(vec, [1, 2]);
@ -565,6 +568,7 @@ impl<T> Vec<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let mut v = vec![1, 2, 3];
/// assert_eq!(v.remove(1), 2);
/// assert_eq!(v, [1, 3]);
@ -696,6 +700,7 @@ impl<T> Vec<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let mut vec = vec![1, 2, 3];
/// let mut vec2 = vec![4, 5, 6];
/// vec.append(&mut vec2);
@ -732,6 +737,7 @@ impl<T> Vec<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let mut v = vec!["a".to_string(), "b".to_string()];
/// for s in v.drain() {
/// // s has type String, not &String
@ -813,6 +819,7 @@ impl<T> Vec<T> {
/// # Examples
///
/// ```
/// # #![feature(collections, core)]
/// let v = vec![0, 1, 2];
/// let w = v.map_in_place(|i| i + 3);
/// assert_eq!(w.as_slice(), [3, 4, 5].as_slice());
@ -1015,6 +1022,7 @@ impl<T> Vec<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let mut vec = vec![1,2,3];
/// let vec2 = vec.split_off(1);
/// assert_eq!(vec, [1]);
@ -1053,6 +1061,7 @@ impl<T: Clone> Vec<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let mut vec = vec!["hello"];
/// vec.resize(3, "world");
/// assert_eq!(vec, ["hello", "world", "world"]);
@ -1081,6 +1090,7 @@ impl<T: Clone> Vec<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let mut vec = vec![1];
/// vec.push_all(&[2, 3, 4]);
/// assert_eq!(vec, [1, 2, 3, 4]);
@ -1554,6 +1564,7 @@ impl<T> AsSlice<T> for Vec<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// fn foo(slice: &[i32]) {}
///
/// let vec = vec![1, 2];

View File

@ -257,6 +257,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::new();
@ -284,6 +285,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecDeque;
///
/// let buf: VecDeque<i32> = VecDeque::with_capacity(10);
@ -307,6 +309,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecDeque;
///
/// let mut buf: VecDeque<i32> = vec![1].into_iter().collect();
@ -328,6 +331,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecDeque;
///
/// let mut buf: VecDeque<i32> = vec![1].into_iter().collect();
@ -403,6 +407,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::with_capacity(15);
@ -489,6 +494,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::new();
@ -512,6 +518,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::new();
@ -535,6 +542,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::new();
@ -644,6 +652,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecDeque;
///
/// let mut v = VecDeque::new();
@ -882,6 +891,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::new();
@ -915,6 +925,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::new();
@ -948,6 +959,7 @@ impl<T> VecDeque<T> {
///
/// # Examples
/// ```
/// # #![feature(collections)]
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::new();
@ -1321,6 +1333,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecDeque;
///
/// let mut buf: VecDeque<_> = vec![1,2,3].into_iter().collect();
@ -1383,6 +1396,7 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecDeque;
///
/// let mut buf: VecDeque<_> = vec![1, 2, 3].into_iter().collect();
@ -1407,6 +1421,7 @@ impl<T: Clone> VecDeque<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecDeque;
///
/// let mut buf = VecDeque::new();

View File

@ -34,6 +34,7 @@ use vec::Vec;
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
///
/// let mut months = VecMap::new();
@ -132,6 +133,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
/// let mut map: VecMap<&str> = VecMap::new();
/// ```
@ -144,6 +146,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
/// let mut map: VecMap<&str> = VecMap::with_capacity(10);
/// ```
@ -158,6 +161,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
/// let map: VecMap<String> = VecMap::with_capacity(10);
/// assert!(map.capacity() >= 10);
@ -177,6 +181,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
/// let mut map: VecMap<&str> = VecMap::new();
/// map.reserve_len(10);
@ -201,6 +206,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
/// let mut map: VecMap<&str> = VecMap::new();
/// map.reserve_len_exact(10);
@ -240,6 +246,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -268,6 +275,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -299,6 +307,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -325,6 +334,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
///
/// let mut a = VecMap::new();
@ -360,6 +370,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
///
/// let mut a = VecMap::new();
@ -416,6 +427,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -443,6 +455,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
///
/// let mut a = VecMap::new();
@ -460,6 +473,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
///
/// let mut a = VecMap::new();
@ -477,6 +491,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
///
/// let mut a = VecMap::new();
@ -492,6 +507,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -516,6 +532,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -534,6 +551,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -562,6 +580,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -587,6 +606,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
///
/// let mut map = VecMap::new();
@ -608,6 +628,7 @@ impl<V> VecMap<V> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// use std::collections::VecMap;
/// use std::collections::vec_map::Entry;
///

View File

@ -220,6 +220,7 @@ impl<T:Copy> Cell<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::cell::Cell;
///
/// let c = Cell::new(5);

View File

@ -19,7 +19,8 @@
//! could do the following:
//!
//! ```
//! use core::num::SignedInt;
//! # #![feature(core)]
//! use std::num::SignedInt;
//!
//! struct FuzzyNum {
//! num: i32,
@ -398,6 +399,7 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::cmp;
///
/// assert_eq!(Some(1), cmp::partial_min(1, 2));
@ -407,6 +409,7 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
/// When comparison is impossible:
///
/// ```
/// # #![feature(core)]
/// use std::cmp;
///
/// let result = cmp::partial_min(std::f64::NAN, 1.0);
@ -429,6 +432,7 @@ pub fn partial_min<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::cmp;
///
/// assert_eq!(Some(2), cmp::partial_max(1, 2));
@ -438,6 +442,7 @@ pub fn partial_min<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
/// When comparison is impossible:
///
/// ```
/// # #![feature(core)]
/// use std::cmp;
///
/// let result = cmp::partial_max(std::f64::NAN, 1.0);

View File

@ -48,6 +48,7 @@
//! For example,
//!
//! ```
//! # #![feature(os, old_io, old_path)]
//! use std::error::FromError;
//! use std::old_io::{File, IoError};
//! use std::os::{MemoryMap, MapError};

View File

@ -19,6 +19,7 @@
//! # Examples
//!
//! ```
//! # #![feature(core)]
//! # #![feature(unboxed_closures)]
//!
//! use std::finally::Finally;
@ -70,6 +71,7 @@ impl<T, F> Finally<T> for F where F: FnMut() -> T {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::finally::try_finally;
///
/// struct State<'a> { buffer: &'a mut [u8], len: usize }

View File

@ -624,6 +624,7 @@ impl<'a> Formatter<'a> {
/// # Examples
///
/// ```rust
/// # #![feature(debug_builders, core)]
/// use std::fmt;
///
/// struct Foo {
@ -655,6 +656,7 @@ impl<'a> Formatter<'a> {
/// # Examples
///
/// ```rust
/// # #![feature(debug_builders, core)]
/// use std::fmt;
///
/// struct Foo(i32, String);
@ -683,6 +685,7 @@ impl<'a> Formatter<'a> {
/// # Examples
///
/// ```rust
/// # #![feature(debug_builders, core)]
/// use std::fmt;
///
/// struct Foo(Vec<i32>);
@ -712,6 +715,7 @@ impl<'a> Formatter<'a> {
/// # Examples
///
/// ```rust
/// # #![feature(debug_builders, core)]
/// use std::fmt;
///
/// struct Foo(Vec<(String, i32)>);

View File

@ -146,6 +146,7 @@ pub struct RadixFmt<T, R>(T, R);
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::fmt::radix;
/// assert_eq!(format!("{}", radix(55, 36)), "1j".to_string());
/// ```

View File

@ -16,6 +16,7 @@
//! # Examples
//!
//! ```rust
//! # #![feature(hash)]
//! use std::hash::{hash, Hash, SipHasher};
//!
//! #[derive(Hash)]
@ -35,6 +36,7 @@
//! the trait `Hash`:
//!
//! ```rust
//! # #![feature(hash)]
//! use std::hash::{hash, Hash, Hasher, SipHasher};
//!
//! struct Person {

View File

@ -262,6 +262,7 @@ extern "rust-intrinsic" {
/// A safe swap function:
///
/// ```
/// # #![feature(core)]
/// use std::mem;
/// use std::ptr;
///
@ -301,6 +302,7 @@ extern "rust-intrinsic" {
/// Efficiently create a Rust vector from an unsafe buffer:
///
/// ```
/// # #![feature(core)]
/// use std::ptr;
///
/// unsafe fn from_buf_raw<T>(ptr: *const T, elts: uint) -> Vec<T> {

View File

@ -334,6 +334,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// let xs = [100, 200, 300];
/// let mut it = xs.iter().cloned().peekable();
/// assert_eq!(*it.peek().unwrap(), 100);
@ -465,6 +466,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// let xs = [2, 3];
/// let ys = [0, 1, 0, 1, 2];
/// let it = xs.iter().flat_map(|&x| std::iter::count(0, 1).take(x));
@ -521,6 +523,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::iter::AdditiveIterator;
///
/// let a = [1, 4, 2, 3, 8, 9, 6];
@ -563,6 +566,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// let a = [1, 2, 3, 4, 5];
/// let b: Vec<_> = a.iter().cloned().collect();
/// assert_eq!(a, b);
@ -579,6 +583,7 @@ pub trait IteratorExt: Iterator + Sized {
/// do not.
///
/// ```
/// # #![feature(core)]
/// let vec = vec![1, 2, 3, 4];
/// let (even, odd): (Vec<_>, Vec<_>) = vec.into_iter().partition(|&n| n % 2 == 0);
/// assert_eq!(even, [2, 4]);
@ -648,6 +653,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// let a = [1, 2, 3, 4, 5];
/// let mut it = a.iter();
/// assert!(it.any(|x| *x == 3));
@ -668,6 +674,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// let a = [1, 2, 3, 4, 5];
/// let mut it = a.iter();
/// assert_eq!(it.find(|&x| *x == 3).unwrap(), &3);
@ -690,6 +697,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// let a = [1, 2, 3, 4, 5];
/// let mut it = a.iter();
/// assert_eq!(it.position(|x| *x == 3).unwrap(), 2);
@ -718,6 +726,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// let a = [1, 2, 2, 4, 5];
/// let mut it = a.iter();
/// assert_eq!(it.rposition(|x| *x == 2).unwrap(), 2);
@ -795,6 +804,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::iter::MinMaxResult::{NoElements, OneElement, MinMax};
///
/// let a: [i32; 0] = [];
@ -860,7 +870,8 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples
///
/// ```
/// use core::num::SignedInt;
/// # #![feature(core)]
/// use std::num::SignedInt;
///
/// let a = [-3, 0, 1, 5, -10];
/// assert_eq!(*a.iter().max_by(|x| x.abs()).unwrap(), -10);
@ -890,7 +901,8 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples
///
/// ```
/// use core::num::SignedInt;
/// # #![feature(core)]
/// use std::num::SignedInt;
///
/// let a = [-3, 0, 1, 5, -10];
/// assert_eq!(*a.iter().min_by(|x| x.abs()).unwrap(), 0);
@ -940,6 +952,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// let a = [(1, 2), (3, 4)];
/// let (left, right): (Vec<_>, Vec<_>) = a.iter().cloned().unzip();
/// assert_eq!([1, 3], left);
@ -1146,6 +1159,7 @@ pub trait AdditiveIterator<A> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::iter::AdditiveIterator;
///
/// let a = [1, 2, 3, 4, 5];
@ -1188,6 +1202,7 @@ pub trait MultiplicativeIterator<A> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::iter::{count, MultiplicativeIterator};
///
/// fn factorial(n: usize) -> usize {
@ -1248,6 +1263,7 @@ impl<T: Clone> MinMaxResult<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::iter::MinMaxResult::{self, NoElements, OneElement, MinMax};
///
/// let r: MinMaxResult<i32> = NoElements;
@ -2292,6 +2308,7 @@ impl<I: RandomAccessIterator, F> RandomAccessIterator for Inspect<I, F>
/// An iterator that yields sequential Fibonacci numbers, and stops on overflow.
///
/// ```
/// # #![feature(core)]
/// use std::iter::Unfold;
/// use std::num::Int; // For `.checked_add()`
///
@ -2693,6 +2710,7 @@ pub struct RangeStepInclusive<A> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::iter::range_step_inclusive;
///
/// for i in range_step_inclusive(0, 10, 2) {

View File

@ -56,6 +56,7 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![doc(test(no_crate_inject))]
#![feature(no_std)]
#![no_std]

View File

@ -231,6 +231,7 @@ macro_rules! writeln {
/// Iterators:
///
/// ```
/// # #![feature(core)]
/// fn divide_by_three(x: u32) -> u32 { // one of the poorest implementations of x/3
/// for i in std::iter::count(0, 1) {
/// if 3*i < i { panic!("u32 overflow"); }

View File

@ -319,6 +319,7 @@ impl<T:?Sized> MarkerTrait for T { }
/// `MarkerTrait`:
///
/// ```
/// # #![feature(core)]
/// use std::marker::MarkerTrait;
/// trait Even : MarkerTrait { }
/// ```

View File

@ -282,7 +282,8 @@ impl Float for f32 {
/// The fractional part of the number, satisfying:
///
/// ```
/// use core::num::Float;
/// # #![feature(core)]
/// use std::num::Float;
///
/// let x = 1.65f32;
/// assert!(x == x.trunc() + x.fract())

View File

@ -289,7 +289,8 @@ impl Float for f64 {
/// The fractional part of the number, satisfying:
///
/// ```
/// use core::num::Float;
/// # #![feature(core)]
/// use std::num::Float;
///
/// let x = 1.65f64;
/// assert!(x == x.trunc() + x.fract())

View File

@ -85,6 +85,7 @@ pub trait Int
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0b01001100u8;
@ -100,6 +101,7 @@ pub trait Int
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0b01001100u8;
@ -119,6 +121,7 @@ pub trait Int
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0b0101000u16;
@ -135,6 +138,7 @@ pub trait Int
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0b0101000u16;
@ -151,6 +155,7 @@ pub trait Int
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0x0123456789ABCDEFu64;
@ -168,6 +173,7 @@ pub trait Int
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0x0123456789ABCDEFu64;
@ -392,6 +398,7 @@ pub trait Int
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::num::Int;
///
/// assert_eq!(2.pow(4), 16);
@ -787,6 +794,7 @@ macro_rules! int_impl {
/// # Examples
///
/// ```rust
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0b01001100u8;
@ -803,6 +811,7 @@ macro_rules! int_impl {
/// # Examples
///
/// ```rust
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0b01001100u8;
@ -822,6 +831,7 @@ macro_rules! int_impl {
/// # Examples
///
/// ```rust
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0b0101000u16;
@ -841,6 +851,7 @@ macro_rules! int_impl {
/// # Examples
///
/// ```rust
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0b0101000u16;
@ -860,6 +871,7 @@ macro_rules! int_impl {
/// # Examples
///
/// ```rust
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0x0123456789ABCDEFu64;
@ -881,6 +893,7 @@ macro_rules! int_impl {
/// # Examples
///
/// ```rust
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0x0123456789ABCDEFu64;
@ -1112,6 +1125,7 @@ macro_rules! int_impl {
/// # Examples
///
/// ```rust
/// # #![feature(core)]
/// use std::num::Int;
///
/// assert_eq!(2.pow(4), 16);
@ -1277,6 +1291,7 @@ macro_rules! uint_impl {
/// # Examples
///
/// ```rust
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0b01001100u8;
@ -1295,6 +1310,7 @@ macro_rules! uint_impl {
/// # Examples
///
/// ```rust
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0b01001100u8;
@ -1314,6 +1330,7 @@ macro_rules! uint_impl {
/// # Examples
///
/// ```rust
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0b0101000u16;
@ -1333,6 +1350,7 @@ macro_rules! uint_impl {
/// # Examples
///
/// ```rust
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0b0101000u16;
@ -1352,6 +1370,7 @@ macro_rules! uint_impl {
/// # Examples
///
/// ```rust
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0x0123456789ABCDEFu64;
@ -1375,6 +1394,7 @@ macro_rules! uint_impl {
/// # Examples
///
/// ```rust
/// # #![feature(core)]
/// use std::num::Int;
///
/// let n = 0x0123456789ABCDEFu64;
@ -1606,6 +1626,7 @@ macro_rules! uint_impl {
/// # Examples
///
/// ```rust
/// # #![feature(core)]
/// use std::num::Int;
///
/// assert_eq!(2.pow(4), 16);
@ -2266,6 +2287,7 @@ impl_from_primitive! { f64, to_f64 }
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::num;
///
/// let twenty: f32 = num::cast(0x14).unwrap();

View File

@ -275,6 +275,7 @@ impl<T> Option<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// let mut x = Some("Diamonds");
/// {
/// let v = x.as_mut_slice();
@ -470,6 +471,7 @@ impl<T> Option<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// let x = Some("foo");
/// assert_eq!(x.ok_or(0), Ok("foo"));
///
@ -491,6 +493,7 @@ impl<T> Option<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// let x = Some("foo");
/// assert_eq!(x.ok_or_else(|| 0), Ok("foo"));
///
@ -532,6 +535,7 @@ impl<T> Option<T> {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// let mut x = Some(4);
/// match x.iter_mut().next() {
/// Some(&mut ref mut v) => *v = 42,

View File

@ -52,6 +52,7 @@
//! the raw pointer. It doesn't destroy `T` or deallocate any memory.
//!
//! ```
//! # #![feature(alloc)]
//! use std::boxed;
//!
//! unsafe {
@ -70,6 +71,7 @@
//! ## 3. Get it from C.
//!
//! ```
//! # #![feature(libc)]
//! extern crate libc;
//!
//! use std::mem;

View File

@ -48,6 +48,7 @@ use mem;
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::raw::{self, Repr};
///
/// let slice: &[u16] = &[1, 2, 3, 4];
@ -106,6 +107,7 @@ pub struct Closure {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::mem;
/// use std::raw;
///

View File

@ -95,6 +95,7 @@
//! by the [`Writer`](../io/trait.Writer.html) trait:
//!
//! ```
//! # #![feature(old_io)]
//! use std::old_io::IoError;
//!
//! trait Writer {
@ -110,6 +111,7 @@
//! something like this:
//!
//! ```{.ignore}
//! # #![feature(old_io)]
//! use std::old_io::*;
//! use std::old_path::Path;
//!
@ -129,6 +131,7 @@
//! a marginally useful message indicating why:
//!
//! ```{.no_run}
//! # #![feature(old_io, old_path)]
//! use std::old_io::*;
//! use std::old_path::Path;
//!
@ -140,6 +143,7 @@
//! You might also simply assert success:
//!
//! ```{.no_run}
//! # #![feature(old_io, old_path)]
//! # use std::old_io::*;
//! # use std::old_path::Path;
//!
@ -151,6 +155,7 @@
//! Or propagate the error up the call stack with `try!`:
//!
//! ```
//! # #![feature(old_io, old_path)]
//! # use std::old_io::*;
//! # use std::old_path::Path;
//! fn write_message() -> Result<(), IoError> {
@ -171,6 +176,7 @@
//! It replaces this:
//!
//! ```
//! # #![feature(old_io, old_path)]
//! use std::old_io::*;
//! use std::old_path::Path;
//!
@ -196,6 +202,7 @@
//! With this:
//!
//! ```
//! # #![feature(old_io, old_path)]
//! use std::old_io::*;
//! use std::old_path::Path;
//!
@ -411,6 +418,7 @@ impl<T, E> Result<T, E> {
/// Convert from `Result<T, E>` to `&mut [T]` (without copying)
///
/// ```
/// # #![feature(core)]
/// let mut x: Result<&str, u32> = Ok("Gold");
/// {
/// let v = x.as_mut_slice();
@ -452,6 +460,7 @@ impl<T, E> Result<T, E> {
/// ignoring I/O and parse errors:
///
/// ```
/// # #![feature(old_io)]
/// use std::old_io::*;
///
/// let mut buffer: &[u8] = b"1\n2\n3\n4\n";

View File

@ -19,7 +19,7 @@
//! provided beyond this module.
//!
//! ```rust
//!
//! # #![feature(core)]
//! fn main() {
//! use std::simd::f32x4;
//! let a = f32x4(40.0, 41.0, 42.0, 43.0);

View File

@ -1491,6 +1491,7 @@ pub unsafe fn from_raw_parts_mut<'a, T>(p: *mut T, len: usize) -> &'a mut [T] {
/// # Examples
///
/// ```
/// #![feature(core)]
/// use std::slice;
///
/// // manifest a slice out of thin air!

View File

@ -47,6 +47,7 @@
//! which is cyclic.
//!
//! ```rust
//! # #![feature(rustc_private, core)]
//! use std::borrow::IntoCow;
//! use std::io::Write;
//! use graphviz as dot;
@ -148,6 +149,7 @@
//! entity `&sube`).
//!
//! ```rust
//! # #![feature(rustc_private, core)]
//! use std::borrow::IntoCow;
//! use std::io::Write;
//! use graphviz as dot;
@ -205,6 +207,7 @@
//! Hasse-diagram for the subsets of the set `{x, y}`.
//!
//! ```rust
//! # #![feature(rustc_private, core)]
//! use std::borrow::IntoCow;
//! use std::io::Write;
//! use graphviz as dot;

View File

@ -5031,7 +5031,7 @@ pub mod funcs {
///
/// # Examples
///
/// ```no_run
/// ```no_run,ignore
/// extern crate libc;
///
/// fn main() {

View File

@ -60,6 +60,7 @@ impl Rand for Exp1 {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand;
/// use std::rand::distributions::{Exp, IndependentSample};
///

View File

@ -40,6 +40,7 @@ use super::{IndependentSample, Sample, Exp};
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand;
/// use std::rand::distributions::{IndependentSample, Gamma};
///
@ -187,6 +188,7 @@ impl IndependentSample<f64> for GammaLargeShape {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand;
/// use std::rand::distributions::{ChiSquared, IndependentSample};
///
@ -244,6 +246,7 @@ impl IndependentSample<f64> for ChiSquared {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand;
/// use std::rand::distributions::{FisherF, IndependentSample};
///
@ -288,6 +291,7 @@ impl IndependentSample<f64> for FisherF {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand;
/// use std::rand::distributions::{StudentT, IndependentSample};
///

View File

@ -94,6 +94,7 @@ pub struct Weighted<T> {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand;
/// use std::rand::distributions::{Weighted, WeightedChoice, IndependentSample};
///

View File

@ -76,6 +76,7 @@ impl Rand for StandardNormal {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand;
/// use std::rand::distributions::{Normal, IndependentSample};
///
@ -124,6 +125,7 @@ impl IndependentSample<f64> for Normal {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand;
/// use std::rand::distributions::{LogNormal, IndependentSample};
///

View File

@ -36,6 +36,7 @@ use distributions::{Sample, IndependentSample};
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand::distributions::{IndependentSample, Range};
///
/// fn main() {

View File

@ -149,6 +149,7 @@ pub trait Rng : Sized {
/// # Examples
///
/// ```
/// # #![feature(rand, core)]
/// use std::rand::{thread_rng, Rng};
///
/// let mut v = [0; 13579];
@ -184,6 +185,7 @@ pub trait Rng : Sized {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand::{thread_rng, Rng};
///
/// let mut rng = thread_rng();
@ -202,6 +204,7 @@ pub trait Rng : Sized {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand::{thread_rng, Rng};
///
/// let mut rng = thread_rng();
@ -229,6 +232,7 @@ pub trait Rng : Sized {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand::{thread_rng, Rng};
///
/// let mut rng = thread_rng();
@ -247,6 +251,7 @@ pub trait Rng : Sized {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand::{thread_rng, Rng};
///
/// let mut rng = thread_rng();
@ -261,6 +266,7 @@ pub trait Rng : Sized {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand::{thread_rng, Rng};
///
/// let s: String = thread_rng().gen_ascii_chars().take(10).collect();
@ -277,6 +283,7 @@ pub trait Rng : Sized {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand::{thread_rng, Rng};
///
/// let choices = [1, 2, 4, 8, 16, 32];
@ -297,6 +304,7 @@ pub trait Rng : Sized {
/// # Examples
///
/// ```
/// # #![feature(rand, core)]
/// use std::rand::{thread_rng, Rng};
///
/// let mut rng = thread_rng();
@ -360,6 +368,7 @@ pub trait SeedableRng<Seed>: Rng {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand::{Rng, SeedableRng, StdRng};
///
/// let seed: &[_] = &[1, 2, 3, 4];
@ -375,6 +384,7 @@ pub trait SeedableRng<Seed>: Rng {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand::{Rng, SeedableRng, StdRng};
///
/// let seed: &[_] = &[1, 2, 3, 4];
@ -480,6 +490,7 @@ impl Rand for XorShiftRng {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand::{random, Open01};
///
/// let Open01(val) = random::<Open01<f32>>();
@ -497,6 +508,7 @@ pub struct Open01<F>(pub F);
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand::{random, Closed01};
///
/// let Closed01(val) = random::<Closed01<f32>>();

View File

@ -103,6 +103,7 @@ impl<S, R: SeedableRng<S>, Rsdr: Reseeder<R> + Default>
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand::{Rng, SeedableRng, StdRng};
/// use std::rand::reseeding::{Reseeder, ReseedingRng};
///

View File

@ -33,6 +33,7 @@
/// # Examples
///
/// ```{.rust}
/// # #![feature(rustc_private)]
/// #[macro_use] extern crate rustc_bitflags;
///
/// bitflags! {
@ -59,6 +60,7 @@
/// The generated `struct`s can also be extended with type and trait implementations:
///
/// ```{.rust}
/// # #![feature(rustc_private)]
/// #[macro_use] extern crate rustc_bitflags;
///
/// use std::fmt;

View File

@ -268,7 +268,7 @@ pub fn maketest(s: &str, cratename: Option<&str>, lints: bool,
// Don't inject `extern crate std` because it's already injected by the
// compiler.
if !s.contains("extern crate") && cratename != Some("std") && inject_crate {
if !s.contains("extern crate") && inject_crate {
match cratename {
Some(cratename) => {
if s.contains(cratename) {

View File

@ -32,6 +32,7 @@ impl ToHex for [u8] {
/// # Examples
///
/// ```
/// # #![feature(rustc_private)]
/// extern crate serialize;
/// use serialize::hex::ToHex;
///
@ -101,6 +102,7 @@ impl FromHex for str {
/// This converts a string literal to hexadecimal and back.
///
/// ```
/// # #![feature(rustc_private)]
/// extern crate serialize;
/// use serialize::hex::{FromHex, ToHex};
///

View File

@ -538,6 +538,7 @@ impl<K, V, S> HashMap<K, V, S>
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// use std::collections::HashMap;
/// use std::collections::hash_map::RandomState;
///
@ -566,6 +567,7 @@ impl<K, V, S> HashMap<K, V, S>
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// use std::collections::HashMap;
/// use std::collections::hash_map::RandomState;
///
@ -981,6 +983,7 @@ impl<K, V, S> HashMap<K, V, S>
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// use std::collections::HashMap;
///
/// let mut a = HashMap::new();

View File

@ -145,6 +145,7 @@ impl<T, S> HashSet<T, S>
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// use std::collections::HashSet;
/// use std::collections::hash_map::RandomState;
///
@ -169,6 +170,7 @@ impl<T, S> HashSet<T, S>
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// use std::collections::HashSet;
/// use std::collections::hash_map::RandomState;
///
@ -295,6 +297,7 @@ impl<T, S> HashSet<T, S>
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::HashSet;
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
@ -325,6 +328,7 @@ impl<T, S> HashSet<T, S>
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::HashSet;
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
@ -351,6 +355,7 @@ impl<T, S> HashSet<T, S>
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::HashSet;
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
@ -376,6 +381,7 @@ impl<T, S> HashSet<T, S>
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::HashSet;
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
@ -458,6 +464,7 @@ impl<T, S> HashSet<T, S>
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::HashSet;
///
/// let set: HashSet<_> = [1, 2, 3].iter().cloned().collect();
@ -477,6 +484,7 @@ impl<T, S> HashSet<T, S>
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::HashSet;
///
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
@ -498,6 +506,7 @@ impl<T, S> HashSet<T, S>
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::HashSet;
///
/// let sup: HashSet<_> = [1, 2, 3].iter().cloned().collect();
@ -519,6 +528,7 @@ impl<T, S> HashSet<T, S>
/// # Examples
///
/// ```
/// # #![feature(core)]
/// use std::collections::HashSet;
///
/// let sub: HashSet<_> = [1, 2].iter().cloned().collect();

View File

@ -300,6 +300,7 @@
//! #### Counting the number of times each character in a string occurs
//!
//! ```
//! # #![feature(collections)]
//! use std::collections::btree_map::{BTreeMap, Entry};
//!
//! let mut count = BTreeMap::new();
@ -327,6 +328,7 @@
//! #### Tracking the inebriation of customers at a bar
//!
//! ```
//! # #![feature(collections)]
//! use std::collections::btree_map::{BTreeMap, Entry};
//!
//! // A client of the bar. They have an id and a blood alcohol level.

View File

@ -44,6 +44,7 @@ use vec::Vec;
/// # Examples
///
/// ```no_run
/// # #![feature(libc)]
/// # extern crate libc;
/// # fn main() {
/// use std::ffi::CString;
@ -82,6 +83,7 @@ pub struct CString {
/// Inspecting a foreign C string
///
/// ```no_run
/// # #![feature(libc)]
/// extern crate libc;
/// use std::ffi::CStr;
///
@ -98,6 +100,7 @@ pub struct CString {
/// Passing a Rust-originating C string
///
/// ```no_run
/// # #![feature(libc)]
/// extern crate libc;
/// use std::ffi::{CString, CStr};
///
@ -144,6 +147,7 @@ impl CString {
/// # Examples
///
/// ```no_run
/// # #![feature(libc)]
/// extern crate libc;
/// use std::ffi::CString;
///
@ -179,6 +183,7 @@ impl CString {
/// # Examples
///
/// ```no_run
/// # #![feature(libc)]
/// extern crate libc;
/// use std::ffi::CString;
///
@ -329,6 +334,7 @@ impl CStr {
/// # Examples
///
/// ```no_run
/// # #![feature(libc)]
/// # extern crate libc;
/// # fn main() {
/// use std::ffi::CStr;

View File

@ -633,6 +633,7 @@ pub fn remove_dir_all<P: AsPath>(path: P) -> io::Result<()> {
/// # Examples
///
/// ```
/// # #![feature(path_ext)]
/// use std::io;
/// use std::fs::{self, PathExt, DirEntry};
/// use std::path::Path;
@ -771,6 +772,7 @@ pub fn set_file_times<P: AsPath>(path: P, accessed: u64,
/// # Examples
///
/// ```
/// # #![feature(fs)]
/// # fn foo() -> std::io::Result<()> {
/// use std::fs;
///

View File

@ -105,6 +105,7 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![doc(test(no_crate_inject))]
#![feature(alloc)]
#![feature(box_syntax)]

View File

@ -112,6 +112,7 @@ macro_rules! try {
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// use std::thread;
/// use std::sync::mpsc;
///

View File

@ -263,6 +263,7 @@ impl hash::Hash for SocketAddrV6 {
/// Some examples:
///
/// ```no_run
/// # #![feature(net)]
/// use std::net::{SocketAddrV4, TcpStream, UdpSocket, TcpListener, Ipv4Addr};
///
/// fn main() {

View File

@ -91,6 +91,7 @@ impl Iterator for LookupHost {
/// # Examples
///
/// ```no_run
/// # #![feature(net)]
/// use std::net;
///
/// # fn foo() -> std::io::Result<()> {

View File

@ -27,6 +27,7 @@ use sys_common::AsInner;
/// # Examples
///
/// ```no_run
/// # #![feature(net)]
/// use std::io::prelude::*;
/// use std::net::TcpStream;
///
@ -46,6 +47,7 @@ pub struct TcpStream(net_imp::TcpStream);
/// # Examples
///
/// ```no_run
/// # #![feature(net)]
/// use std::net::{TcpListener, TcpStream};
/// use std::thread;
///

View File

@ -27,6 +27,7 @@ use sys_common::AsInner;
/// # Examples
///
/// ```no_run
/// # #![feature(net)]
/// use std::net::UdpSocket;
///
/// # fn foo() -> std::io::Result<()> {

View File

@ -365,6 +365,7 @@ impl f32 {
/// Returns the `NaN` value.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let nan: f32 = Float::nan();
@ -379,6 +380,7 @@ impl f32 {
/// Returns the infinite value.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f32;
///
@ -396,6 +398,7 @@ impl f32 {
/// Returns the negative infinite value.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f32;
///
@ -413,6 +416,7 @@ impl f32 {
/// Returns `0.0`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let inf: f32 = Float::infinity();
@ -431,6 +435,7 @@ impl f32 {
/// Returns `-0.0`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let inf: f32 = Float::infinity();
@ -449,6 +454,7 @@ impl f32 {
/// Returns `1.0`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let one: f32 = Float::one();
@ -525,6 +531,7 @@ impl f32 {
/// Returns the smallest finite value that this type can represent.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f64;
///
@ -548,6 +555,7 @@ impl f32 {
/// Returns the largest finite value that this type can represent.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f64;
///
@ -563,6 +571,7 @@ impl f32 {
/// Returns `true` if this value is `NaN` and false otherwise.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f64;
///
@ -580,6 +589,7 @@ impl f32 {
/// false otherwise.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f32;
///
@ -601,6 +611,7 @@ impl f32 {
/// Returns `true` if this number is neither infinite nor `NaN`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f32;
///
@ -623,6 +634,7 @@ impl f32 {
/// [subnormal][subnormal], or `NaN`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f32;
///
@ -650,6 +662,7 @@ impl f32 {
/// predicate instead.
///
/// ```
/// # #![feature(core)]
/// use std::num::{Float, FpCategory};
/// use std::f32;
///
@ -668,6 +681,7 @@ impl f32 {
/// The floating point encoding is documented in the [Reference][floating-point].
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let num = 2.0f32;
@ -770,6 +784,7 @@ impl f32 {
/// number is `Float::nan()`.
///
/// ```
/// # #![feature(core, std_misc)]
/// use std::num::Float;
/// use std::f64;
///
@ -795,6 +810,7 @@ impl f32 {
/// - `Float::nan()` if the number is `Float::nan()`
///
/// ```
/// # #![feature(core, std_misc)]
/// use std::num::Float;
/// use std::f64;
///
@ -856,6 +872,7 @@ impl f32 {
/// a separate multiplication operation followed by an add.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let m = 10.0;
@ -875,6 +892,7 @@ impl f32 {
/// Take the reciprocal (inverse) of a number, `1/x`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 2.0;
@ -922,6 +940,7 @@ impl f32 {
/// Returns NaN if `self` is a negative number.
///
/// ```
/// # #![feature(core, std_misc)]
/// use std::num::Float;
///
/// let positive = 4.0;
@ -940,6 +959,7 @@ impl f32 {
/// Take the reciprocal (inverse) square root of a number, `1/sqrt(x)`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let f = 4.0;
@ -1061,6 +1081,7 @@ impl f32 {
/// Convert radians to degrees.
///
/// ```
/// # #![feature(std_misc, core)]
/// use std::num::Float;
/// use std::f64::consts;
///
@ -1077,6 +1098,7 @@ impl f32 {
/// Convert degrees to radians.
///
/// ```
/// # #![feature(std_misc, core)]
/// use std::num::Float;
/// use std::f64::consts;
///
@ -1093,6 +1115,7 @@ impl f32 {
/// Constructs a floating point number of `x*2^exp`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// // 3*2^2 - 12 == 0
@ -1114,6 +1137,7 @@ impl f32 {
/// * `0.5 <= abs(x) < 1.0`
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 4.0;
@ -1141,6 +1165,7 @@ impl f32 {
/// `other`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 1.0f32;
@ -1194,6 +1219,7 @@ impl f32 {
/// * Else: `self - other`
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 3.0;
@ -1214,6 +1240,7 @@ impl f32 {
/// Take the cubic root of a number.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 8.0;
@ -1233,6 +1260,7 @@ impl f32 {
/// legs of length `x` and `y`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 2.0;
@ -1253,6 +1281,7 @@ impl f32 {
/// Computes the sine of a number (in radians).
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1271,6 +1300,7 @@ impl f32 {
/// Computes the cosine of a number (in radians).
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1289,6 +1319,7 @@ impl f32 {
/// Computes the tangent of a number (in radians).
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1308,6 +1339,7 @@ impl f32 {
/// [-1, 1].
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1329,6 +1361,7 @@ impl f32 {
/// [-1, 1].
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1372,6 +1405,7 @@ impl f32 {
/// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)`
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1401,6 +1435,7 @@ impl f32 {
/// `(sin(x), cos(x))`.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1423,6 +1458,7 @@ impl f32 {
/// number is close to zero.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 7.0;
@ -1442,6 +1478,7 @@ impl f32 {
/// the operations were performed separately.
///
/// ```
/// # #![feature(std_misc, core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1461,6 +1498,7 @@ impl f32 {
/// Hyperbolic sine function.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1483,6 +1521,7 @@ impl f32 {
/// Hyperbolic cosine function.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1505,6 +1544,7 @@ impl f32 {
/// Hyperbolic tangent function.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1527,6 +1567,7 @@ impl f32 {
/// Inverse hyperbolic sine function.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
///
/// let x = 1.0;
@ -1548,6 +1589,7 @@ impl f32 {
/// Inverse hyperbolic cosine function.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
///
/// let x = 1.0;
@ -1569,6 +1611,7 @@ impl f32 {
/// Inverse hyperbolic tangent function.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///

View File

@ -374,6 +374,7 @@ impl f64 {
/// Returns the `NaN` value.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let nan: f32 = Float::nan();
@ -388,6 +389,7 @@ impl f64 {
/// Returns the infinite value.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f32;
///
@ -405,6 +407,7 @@ impl f64 {
/// Returns the negative infinite value.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f32;
///
@ -422,6 +425,7 @@ impl f64 {
/// Returns `0.0`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let inf: f32 = Float::infinity();
@ -440,6 +444,7 @@ impl f64 {
/// Returns `-0.0`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let inf: f32 = Float::infinity();
@ -458,6 +463,7 @@ impl f64 {
/// Returns `1.0`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let one: f32 = Float::one();
@ -534,6 +540,7 @@ impl f64 {
/// Returns the smallest finite value that this type can represent.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f64;
///
@ -557,6 +564,7 @@ impl f64 {
/// Returns the largest finite value that this type can represent.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f64;
///
@ -572,6 +580,7 @@ impl f64 {
/// Returns `true` if this value is `NaN` and false otherwise.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f64;
///
@ -589,6 +598,7 @@ impl f64 {
/// false otherwise.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f32;
///
@ -610,6 +620,7 @@ impl f64 {
/// Returns `true` if this number is neither infinite nor `NaN`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f32;
///
@ -632,6 +643,7 @@ impl f64 {
/// [subnormal][subnormal], or `NaN`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f32;
///
@ -659,6 +671,7 @@ impl f64 {
/// predicate instead.
///
/// ```
/// # #![feature(core)]
/// use std::num::{Float, FpCategory};
/// use std::f32;
///
@ -677,6 +690,7 @@ impl f64 {
/// The floating point encoding is documented in the [Reference][floating-point].
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let num = 2.0f32;
@ -779,6 +793,7 @@ impl f64 {
/// number is `Float::nan()`.
///
/// ```
/// # #![feature(core, std_misc)]
/// use std::num::Float;
/// use std::f64;
///
@ -804,6 +819,7 @@ impl f64 {
/// - `Float::nan()` if the number is `Float::nan()`
///
/// ```
/// # #![feature(core, std_misc)]
/// use std::num::Float;
/// use std::f64;
///
@ -865,6 +881,7 @@ impl f64 {
/// a separate multiplication operation followed by an add.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let m = 10.0;
@ -884,6 +901,7 @@ impl f64 {
/// Take the reciprocal (inverse) of a number, `1/x`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 2.0;
@ -931,6 +949,7 @@ impl f64 {
/// Returns NaN if `self` is a negative number.
///
/// ```
/// # #![feature(core, std_misc)]
/// use std::num::Float;
///
/// let positive = 4.0;
@ -948,6 +967,7 @@ impl f64 {
/// Take the reciprocal (inverse) square root of a number, `1/sqrt(x)`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let f = 4.0;
@ -1069,6 +1089,7 @@ impl f64 {
/// Convert radians to degrees.
///
/// ```
/// # #![feature(std_misc, core)]
/// use std::num::Float;
/// use std::f64::consts;
///
@ -1085,6 +1106,7 @@ impl f64 {
/// Convert degrees to radians.
///
/// ```
/// # #![feature(std_misc, core)]
/// use std::num::Float;
/// use std::f64::consts;
///
@ -1101,6 +1123,7 @@ impl f64 {
/// Constructs a floating point number of `x*2^exp`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// // 3*2^2 - 12 == 0
@ -1122,6 +1145,7 @@ impl f64 {
/// * `0.5 <= abs(x) < 1.0`
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 4.0;
@ -1149,6 +1173,7 @@ impl f64 {
/// `other`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 1.0f32;
@ -1202,6 +1227,7 @@ impl f64 {
/// * Else: `self - other`
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 3.0;
@ -1222,6 +1248,7 @@ impl f64 {
/// Take the cubic root of a number.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 8.0;
@ -1241,6 +1268,7 @@ impl f64 {
/// legs of length `x` and `y`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 2.0;
@ -1261,6 +1289,7 @@ impl f64 {
/// Computes the sine of a number (in radians).
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1279,6 +1308,7 @@ impl f64 {
/// Computes the cosine of a number (in radians).
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1297,6 +1327,7 @@ impl f64 {
/// Computes the tangent of a number (in radians).
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1316,6 +1347,7 @@ impl f64 {
/// [-1, 1].
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1337,6 +1369,7 @@ impl f64 {
/// [-1, 1].
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1380,6 +1413,7 @@ impl f64 {
/// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)`
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1409,6 +1443,7 @@ impl f64 {
/// `(sin(x), cos(x))`.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1431,6 +1466,7 @@ impl f64 {
/// number is close to zero.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 7.0;
@ -1450,6 +1486,7 @@ impl f64 {
/// the operations were performed separately.
///
/// ```
/// # #![feature(std_misc, core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1469,6 +1506,7 @@ impl f64 {
/// Hyperbolic sine function.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1491,6 +1529,7 @@ impl f64 {
/// Hyperbolic cosine function.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1513,6 +1552,7 @@ impl f64 {
/// Hyperbolic tangent function.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1577,6 +1617,7 @@ impl f64 {
/// Inverse hyperbolic tangent function.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///

View File

@ -55,6 +55,7 @@ pub trait Float
/// Returns the `NaN` value.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let nan: f32 = Float::nan();
@ -67,6 +68,7 @@ pub trait Float
/// Returns the infinite value.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f32;
///
@ -82,6 +84,7 @@ pub trait Float
/// Returns the negative infinite value.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f32;
///
@ -97,6 +100,7 @@ pub trait Float
/// Returns `0.0`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let inf: f32 = Float::infinity();
@ -113,6 +117,7 @@ pub trait Float
/// Returns `-0.0`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let inf: f32 = Float::infinity();
@ -129,6 +134,7 @@ pub trait Float
/// Returns `1.0`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let one: f32 = Float::one();
@ -182,6 +188,7 @@ pub trait Float
/// Returns the smallest finite value that this type can represent.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f64;
///
@ -199,6 +206,7 @@ pub trait Float
/// Returns the largest finite value that this type can represent.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f64;
///
@ -211,6 +219,7 @@ pub trait Float
/// Returns `true` if this value is `NaN` and false otherwise.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f64;
///
@ -226,6 +235,7 @@ pub trait Float
/// false otherwise.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f32;
///
@ -245,6 +255,7 @@ pub trait Float
/// Returns `true` if this number is neither infinite nor `NaN`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f32;
///
@ -265,6 +276,7 @@ pub trait Float
/// [subnormal][subnormal], or `NaN`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f32;
///
@ -291,6 +303,7 @@ pub trait Float
/// predicate instead.
///
/// ```
/// # #![feature(core)]
/// use std::num::{Float, FpCategory};
/// use std::f32;
///
@ -308,6 +321,7 @@ pub trait Float
/// The floating point encoding is documented in the [Reference][floating-point].
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let num = 2.0f32;
@ -399,6 +413,7 @@ pub trait Float
/// number is `Float::nan()`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f64;
///
@ -422,6 +437,7 @@ pub trait Float
/// - `Float::nan()` if the number is `Float::nan()`
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
/// use std::f64;
///
@ -478,6 +494,7 @@ pub trait Float
/// a separate multiplication operation followed by an add.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let m = 10.0;
@ -495,6 +512,7 @@ pub trait Float
/// Take the reciprocal (inverse) of a number, `1/x`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 2.0;
@ -537,6 +555,7 @@ pub trait Float
/// Returns NaN if `self` is a negative number.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let positive = 4.0;
@ -553,6 +572,7 @@ pub trait Float
/// Take the reciprocal (inverse) square root of a number, `1/sqrt(x)`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let f = 4.0;
@ -662,6 +682,7 @@ pub trait Float
/// Convert radians to degrees.
///
/// ```
/// # #![feature(std_misc, core)]
/// use std::num::Float;
/// use std::f64::consts;
///
@ -676,6 +697,7 @@ pub trait Float
/// Convert degrees to radians.
///
/// ```
/// # #![feature(std_misc, core)]
/// use std::num::Float;
/// use std::f64::consts;
///
@ -690,6 +712,7 @@ pub trait Float
/// Constructs a floating point number of `x*2^exp`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// // 3*2^2 - 12 == 0
@ -707,6 +730,7 @@ pub trait Float
/// * `0.5 <= abs(x) < 1.0`
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 4.0;
@ -726,6 +750,7 @@ pub trait Float
/// `other`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 1.0f32;
@ -769,6 +794,7 @@ pub trait Float
/// * Else: `self - other`
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 3.0;
@ -785,6 +811,7 @@ pub trait Float
/// Take the cubic root of a number.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 8.0;
@ -800,6 +827,7 @@ pub trait Float
/// legs of length `x` and `y`.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 2.0;
@ -817,6 +845,7 @@ pub trait Float
/// Computes the sine of a number (in radians).
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -831,6 +860,7 @@ pub trait Float
/// Computes the cosine of a number (in radians).
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -845,6 +875,7 @@ pub trait Float
/// Computes the tangent of a number (in radians).
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -860,6 +891,7 @@ pub trait Float
/// [-1, 1].
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -877,6 +909,7 @@ pub trait Float
/// [-1, 1].
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -912,6 +945,7 @@ pub trait Float
/// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)`
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -937,6 +971,7 @@ pub trait Float
/// `(sin(x), cos(x))`.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -956,6 +991,7 @@ pub trait Float
/// number is close to zero.
///
/// ```
/// # #![feature(std_misc)]
/// use std::num::Float;
///
/// let x = 7.0;
@ -971,6 +1007,7 @@ pub trait Float
/// the operations were performed separately.
///
/// ```
/// # #![feature(std_misc, core)]
/// use std::num::Float;
/// use std::f64;
///
@ -987,6 +1024,7 @@ pub trait Float
/// Hyperbolic sine function.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1005,6 +1043,7 @@ pub trait Float
/// Hyperbolic cosine function.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1023,6 +1062,7 @@ pub trait Float
/// Hyperbolic tangent function.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///
@ -1069,6 +1109,7 @@ pub trait Float
/// Inverse hyperbolic tangent function.
///
/// ```
/// # #![feature(core)]
/// use std::num::Float;
/// use std::f64;
///

View File

@ -33,6 +33,7 @@ use vec::Vec;
/// # Examples
///
/// ```
/// # #![feature(old_io, old_path)]
/// use std::old_io::*;
/// use std::old_path::Path;
///
@ -137,6 +138,7 @@ impl<R: Reader> Reader for BufferedReader<R> {
/// # Examples
///
/// ```
/// # #![feature(old_io, old_path)]
/// use std::old_io::*;
/// use std::old_path::Path;
///
@ -324,6 +326,7 @@ impl<W: Reader> Reader for InternalBufferedWriter<W> {
/// # Examples
///
/// ```
/// # #![feature(old_io, old_path)]
/// # #![allow(unused_must_use)]
/// use std::old_io::*;
/// use std::old_path::Path;

View File

@ -23,6 +23,7 @@ use vec::Vec;
/// # Examples
///
/// ```
/// # #![feature(old_io)]
/// use std::sync::mpsc::channel;
/// use std::old_io::*;
///
@ -114,6 +115,7 @@ impl Reader for ChanReader {
/// # Examples
///
/// ```
/// # #![feature(old_io, io)]
/// # #![allow(unused_must_use)]
/// use std::sync::mpsc::channel;
/// use std::old_io::*;

View File

@ -30,6 +30,7 @@
//! # Examples
//!
//! ```rust
//! # #![feature(old_io, io, old_path)]
//! # #![allow(unused_must_use)]
//! use std::old_io::fs::PathExtensions;
//! use std::old_io::*;
@ -105,6 +106,7 @@ impl File {
/// # Examples
///
/// ```rust,should_fail
/// # #![feature(old_io, old_path)]
/// use std::old_io::*;
/// use std::old_path::Path;
///
@ -177,6 +179,7 @@ impl File {
/// # Examples
///
/// ```
/// # #![feature(old_io, old_path)]
/// use std::old_io::*;
/// use std::old_path::Path;
///
@ -197,6 +200,7 @@ impl File {
/// # Examples
///
/// ```
/// # #![feature(old_io, old_path, io)]
/// # #![allow(unused_must_use)]
/// use std::old_io::*;
/// use std::old_path::Path;
@ -289,6 +293,7 @@ impl File {
/// # Examples
///
/// ```
/// # #![feature(old_io, old_path)]
/// # #![allow(unused_must_use)]
/// use std::old_io::*;
/// use std::old_path::Path;
@ -321,6 +326,7 @@ pub fn unlink(path: &Path) -> IoResult<()> {
/// # Examples
///
/// ```
/// # #![feature(old_io, old_path)]
/// use std::old_io::*;
/// use std::old_path::Path;
///
@ -364,6 +370,7 @@ pub fn lstat(path: &Path) -> IoResult<FileStat> {
/// # Examples
///
/// ```
/// # #![feature(old_io, old_path)]
/// # #![allow(unused_must_use)]
/// use std::old_io::*;
/// use std::old_path::Path;
@ -393,6 +400,7 @@ pub fn rename(from: &Path, to: &Path) -> IoResult<()> {
/// # Examples
///
/// ```
/// # #![feature(old_io, old_path)]
/// # #![allow(unused_must_use)]
/// use std::old_io::*;
/// use std::old_path::Path;
@ -444,6 +452,7 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> {
/// # Examples
///
/// ```
/// # #![feature(old_io, old_path)]
/// # #![allow(unused_must_use)]
/// use std::old_io;
/// use std::old_io::*;
@ -516,6 +525,7 @@ pub fn readlink(path: &Path) -> IoResult<Path> {
/// # Examples
///
/// ```
/// # #![feature(old_io, old_path, old_fs)]
/// # #![allow(unused_must_use)]
/// use std::old_io;
/// use std::old_io::*;
@ -541,6 +551,7 @@ pub fn mkdir(path: &Path, mode: FilePermission) -> IoResult<()> {
/// # Examples
///
/// ```
/// # #![feature(old_io, old_path)]
/// # #![allow(unused_must_use)]
/// use std::old_io::*;
/// use std::old_path::Path;
@ -566,6 +577,7 @@ pub fn rmdir(path: &Path) -> IoResult<()> {
/// # Examples
///
/// ```
/// # #![feature(old_io, old_path)]
/// use std::old_io::fs::PathExtensions;
/// use std::old_io;
/// use std::old_io::*;

View File

@ -54,6 +54,7 @@ impl Writer for Vec<u8> {
/// # Examples
///
/// ```
/// # #![feature(old_io, io)]
/// # #![allow(unused_must_use)]
/// use std::old_io::*;
///
@ -114,6 +115,7 @@ impl Writer for MemWriter {
/// # Examples
///
/// ```
/// # #![feature(old_io)]
/// # #![allow(unused_must_use)]
/// use std::old_io::*;
///
@ -244,6 +246,7 @@ impl<'a> Buffer for &'a [u8] {
/// # Examples
///
/// ```
/// # #![feature(old_io, io)]
/// # #![allow(unused_must_use)]
/// use std::old_io::*;
///
@ -316,6 +319,7 @@ impl<'a> Seek for BufWriter<'a> {
/// # Examples
///
/// ```
/// # #![feature(old_io)]
/// # #![allow(unused_must_use)]
/// use std::old_io::*;
///

View File

@ -48,6 +48,7 @@
//! * Read lines from stdin
//!
//! ```rust
//! # #![feature(old_io, old_path)]
//! use std::old_io as io;
//! use std::old_io::*;
//!
@ -60,6 +61,7 @@
//! * Read a complete file
//!
//! ```rust
//! # #![feature(old_io, old_path)]
//! use std::old_io::*;
//! use std::old_path::Path;
//!
@ -69,6 +71,7 @@
//! * Write a line to a file
//!
//! ```rust
//! # #![feature(old_io, old_path)]
//! # #![allow(unused_must_use)]
//! use std::old_io::*;
//! use std::old_path::Path;
@ -82,6 +85,7 @@
//! * Iterate over the lines of a file
//!
//! ```rust,no_run
//! # #![feature(old_io, old_path)]
//! use std::old_io::*;
//! use std::old_path::Path;
//!
@ -95,6 +99,7 @@
//! * Pull the lines of a file into a vector of strings
//!
//! ```rust,no_run
//! # #![feature(old_io, old_path)]
//! use std::old_io::*;
//! use std::old_path::Path;
//!
@ -106,6 +111,7 @@
//! * Make a simple TCP client connection and request
//!
//! ```rust
//! # #![feature(old_io)]
//! # #![allow(unused_must_use)]
//! use std::old_io::*;
//!
@ -122,6 +128,7 @@
//! * Make a simple TCP server
//!
//! ```rust
//! # #![feature(old_io)]
//! # fn main() { }
//! # fn foo() {
//! # #![allow(dead_code)]
@ -186,6 +193,7 @@
//! If you wanted to handle the error though you might write:
//!
//! ```rust
//! # #![feature(old_io, old_path)]
//! # #![allow(unused_must_use)]
//! use std::old_io::*;
//! use std::old_path::Path;
@ -221,6 +229,7 @@
//! If you wanted to read several `u32`s from a file and return their product:
//!
//! ```rust
//! # #![feature(old_io, old_path)]
//! use std::old_io::*;
//! use std::old_path::Path;
//!
@ -948,6 +957,7 @@ unsafe fn slice_vec_capacity<'a, T>(v: &'a mut Vec<T>, start: uint, end: uint) -
/// # Examples
///
/// ```
/// # #![feature(old_io)]
/// use std::old_io as io;
/// use std::old_io::*;
/// use std::old_io::util::LimitReader;
@ -1282,6 +1292,7 @@ impl<'a> Writer for &'a mut (Writer+'a) {
/// # Examples
///
/// ```
/// # #![feature(old_io)]
/// use std::old_io::util::TeeReader;
/// use std::old_io::*;
///
@ -1407,6 +1418,7 @@ pub trait Buffer: Reader {
/// # Examples
///
/// ```
/// # #![feature(old_io)]
/// use std::old_io::*;
///
/// let mut reader = BufReader::new(b"hello\nworld");
@ -1631,6 +1643,7 @@ impl<'a, T, A: ?Sized + Acceptor<T>> Iterator for IncomingConnections<'a, A> {
/// # Examples
///
/// ```
/// # #![feature(old_io)]
/// use std::old_io as io;
///
/// let eof = io::standard_error(io::EndOfFile);
@ -1719,6 +1732,7 @@ pub enum FileType {
/// # Examples
///
/// ```no_run
/// # #![feature(old_io, old_path)]
///
/// use std::old_io::fs::PathExtensions;
/// use std::old_path::Path;

View File

@ -414,6 +414,7 @@ pub struct ParseError;
/// Some examples:
///
/// ```rust,no_run
/// # #![feature(old_io, core)]
/// # #![allow(unused_must_use)]
///
/// use std::old_io::{TcpStream, TcpListener};

View File

@ -54,6 +54,7 @@ impl UnixStream {
/// # Examples
///
/// ```
/// # #![feature(old_io, old_path, io)]
/// # #![allow(unused_must_use)]
/// use std::old_io::net::pipe::UnixStream;
/// use std::old_io::*;
@ -181,6 +182,7 @@ impl UnixListener {
/// # Examples
///
/// ```
/// # #![feature(old_io, io, old_path)]
/// # fn foo() {
/// use std::old_io::net::pipe::UnixListener;
/// use std::old_io::*;

View File

@ -41,6 +41,7 @@ use sys_common;
/// # Examples
///
/// ```no_run
/// # #![feature(old_io, io)]
/// use std::old_io::*;
///
/// {
@ -133,6 +134,7 @@ impl TcpStream {
/// # Examples
///
/// ```no_run
/// # #![feature(old_io, std_misc)]
/// # #![allow(unused_must_use)]
/// use std::old_io::*;
/// use std::time::Duration;
@ -278,6 +280,7 @@ impl sys_common::AsInner<TcpStreamImp> for TcpStream {
/// # Examples
///
/// ```
/// # #![feature(old_io)]
/// # fn foo() {
/// use std::old_io::*;
/// use std::thread;
@ -374,6 +377,7 @@ impl TcpAcceptor {
/// # Examples
///
/// ```no_run
/// # #![feature(old_io, io)]
/// use std::old_io::*;
///
/// let mut a = TcpListener::bind("127.0.0.1:8482").listen().unwrap();
@ -417,6 +421,7 @@ impl TcpAcceptor {
/// # Examples
///
/// ```
/// # #![feature(old_io, io)]
/// use std::old_io::*;
/// use std::thread;
///

View File

@ -31,6 +31,7 @@ use sys_common;
/// # Examples
///
/// ```rust,no_run
/// # #![feature(old_io)]
/// # #![allow(unused_must_use)]
///
/// use std::old_io::net::udp::UdpSocket;

View File

@ -46,6 +46,7 @@ impl PipeStream {
/// # Examples
///
/// ```{rust,no_run}
/// # #![feature(old_io, libc, io)]
/// # #![allow(unused_must_use)]
/// extern crate libc;
///

View File

@ -61,6 +61,7 @@ use thread;
/// # Examples
///
/// ```should_fail
/// # #![feature(old_io)]
/// use std::old_io::*;
///
/// let mut child = match Command::new("/bin/cat").arg("file.txt").spawn() {
@ -164,6 +165,7 @@ pub type EnvMap = HashMap<EnvKey, CString>;
/// to be changed (for example, by adding arguments) prior to spawning:
///
/// ```
/// # #![feature(old_io)]
/// use std::old_io::*;
///
/// let mut process = match Command::new("sh").arg("-c").arg("echo hello").spawn() {
@ -365,6 +367,7 @@ impl Command {
/// # Examples
///
/// ```
/// # #![feature(old_io, core)]
/// use std::old_io::Command;
///
/// let output = match Command::new("cat").arg("foot.txt").output() {
@ -386,6 +389,7 @@ impl Command {
/// # Examples
///
/// ```
/// # #![feature(old_io)]
/// use std::old_io::Command;
///
/// let status = match Command::new("ls").status() {
@ -660,6 +664,7 @@ impl Process {
/// # Examples
///
/// ```no_run
/// # #![feature(old_io, io)]
/// use std::old_io::{Command, IoResult};
/// use std::old_io::process::ProcessExit;
///

View File

@ -18,6 +18,7 @@
//! # Examples
//!
//! ```rust
//! # #![feature(old_io)]
//! # #![allow(unused_must_use)]
//! use std::old_io;
//! use std::old_io::*;
@ -140,6 +141,7 @@ impl StdinReader {
/// # Examples
///
/// ```
/// # #![feature(old_io)]
/// use std::old_io;
/// use std::old_io::*;
///

View File

@ -29,6 +29,7 @@ use string::String;
/// # Examples
///
/// ```no_run
/// # #![feature(old_io, old_path)]
/// use std::old_io::*;
/// use std::old_path::{Path, GenericPath};
///

View File

@ -31,6 +31,7 @@ use sys::timer::Timer as TimerImp;
/// # Examples
///
/// ```
/// # #![feature(old_io, std_misc)]
/// # fn foo() {
/// use std::old_io::Timer;
/// use std::time::Duration;
@ -54,6 +55,7 @@ use sys::timer::Timer as TimerImp;
/// the `old_io::timer` module.
///
/// ```
/// # #![feature(old_io, std_misc)]
/// # fn foo() {
/// use std::old_io::timer;
/// use std::time::Duration;
@ -116,6 +118,7 @@ impl Timer {
/// # Examples
///
/// ```
/// # #![feature(old_io, std_misc)]
/// use std::old_io::Timer;
/// use std::time::Duration;
///
@ -129,6 +132,7 @@ impl Timer {
/// ```
///
/// ```
/// # #![feature(old_io, std_misc)]
/// use std::old_io::Timer;
/// use std::time::Duration;
///
@ -168,6 +172,7 @@ impl Timer {
/// # Examples
///
/// ```
/// # #![feature(old_io, std_misc)]
/// use std::old_io::Timer;
/// use std::time::Duration;
///
@ -187,6 +192,7 @@ impl Timer {
/// ```
///
/// ```
/// # #![feature(old_io, std_misc)]
/// use std::old_io::Timer;
/// use std::time::Duration;
///

View File

@ -49,6 +49,7 @@
//! ## Examples
//!
//! ```rust
//! # #![feature(old_path, old_io)]
//! use std::old_io::fs::PathExtensions;
//! use std::old_path::{Path, GenericPath};
//!
@ -143,6 +144,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -168,6 +170,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -191,6 +194,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -209,6 +213,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -224,6 +229,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -240,6 +246,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -259,6 +266,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -277,6 +285,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -293,6 +302,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -313,6 +323,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -329,6 +340,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -349,6 +361,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -377,6 +390,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -398,6 +412,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -426,6 +441,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -445,6 +461,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -472,6 +489,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -523,6 +541,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -549,6 +568,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -574,6 +594,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -594,6 +615,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -610,6 +632,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -635,6 +658,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -665,6 +689,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -683,6 +708,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -709,6 +735,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -732,6 +759,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -750,6 +778,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -769,6 +798,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -789,6 +819,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}
@ -806,6 +837,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// # foo();
/// # #[cfg(windows)] fn foo() {}

View File

@ -605,6 +605,7 @@ impl Path {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// println!("{}", Path::new(r"C:\some\path").display());
/// ```
@ -620,6 +621,7 @@ impl Path {
/// # Examples
///
/// ```
/// # #![feature(old_path)]
/// use std::old_path::{Path, GenericPath};
/// let path = Path::new_opt(r"C:\some\path");
///

View File

@ -125,6 +125,7 @@ pub const TMPBUF_SZ : uint = 1000;
/// # Examples
///
/// ```
/// # #![feature(os, old_path)]
/// use std::os;
/// use std::old_path::{Path, GenericPath};
///
@ -146,6 +147,7 @@ pub fn getcwd() -> IoResult<Path> {
/// # Examples
///
/// ```
/// # #![feature(os)]
/// use std::os;
///
/// // We will iterate through the references to the element returned by os::env();
@ -182,6 +184,7 @@ pub fn env_as_bytes() -> Vec<(Vec<u8>, Vec<u8>)> {
/// # Examples
///
/// ```
/// # #![feature(os)]
/// use std::os;
///
/// let key = "HOME";
@ -224,6 +227,7 @@ fn byteify(s: OsString) -> Vec<u8> {
/// # Examples
///
/// ```
/// # #![feature(os)]
/// use std::os;
///
/// let key = "KEY";
@ -265,6 +269,7 @@ pub fn unsetenv(n: &str) {
/// # Examples
///
/// ```
/// # #![feature(old_path, os)]
/// use std::os;
/// use std::old_path::{Path, GenericPath};
///
@ -298,6 +303,7 @@ pub fn split_paths<T: BytesContainer>(unparsed: T) -> Vec<Path> {
/// # Examples
///
/// ```
/// # #![feature(os, old_path, core)]
/// use std::os;
/// use std::old_path::Path;
///
@ -359,6 +365,7 @@ pub fn dll_filename(base: &str) -> String {
/// # Examples
///
/// ```
/// # #![feature(os, old_path)]
/// use std::os;
/// use std::old_path::{Path, GenericPath};
///
@ -380,6 +387,7 @@ pub fn self_exe_name() -> Option<Path> {
/// # Examples
///
/// ```
/// # #![feature(os, old_path)]
/// use std::os;
/// use std::old_path::{Path, GenericPath};
///
@ -410,6 +418,7 @@ pub fn self_exe_path() -> Option<Path> {
/// # Examples
///
/// ```
/// # #![feature(os, old_path)]
/// use std::os;
/// use std::old_path::{Path, GenericPath};
///
@ -501,6 +510,7 @@ pub fn tmpdir() -> Path {
/// # Examples
///
/// ```
/// # #![feature(os, old_path)]
/// use std::os;
/// use std::old_path::{Path, GenericPath};
///
@ -533,6 +543,7 @@ pub fn make_absolute(p: &Path) -> IoResult<Path> {
/// # Examples
///
/// ```
/// # #![feature(os, old_path)]
/// use std::os;
/// use std::old_path::{Path, GenericPath};
///
@ -555,6 +566,7 @@ pub fn errno() -> i32 {
/// # Examples
///
/// ```
/// # #![feature(os)]
/// use std::os;
///
/// // Same as println!("{}", last_os_error());
@ -751,6 +763,7 @@ extern "system" {
/// # Examples
///
/// ```
/// # #![feature(os)]
/// use std::os;
///
/// // Prints each argument on a separate line

View File

@ -58,6 +58,7 @@
//! # Examples
//!
//! ```rust
//! # #![feature(rand)]
//! use std::rand;
//! use std::rand::Rng;
//!
@ -68,6 +69,7 @@
//! ```
//!
//! ```rust
//! # #![feature(rand)]
//! use std::rand;
//!
//! let tuple = rand::random::<(f64, char)>();
@ -92,6 +94,7 @@
//! multiply this fraction by 4.
//!
//! ```
//! # #![feature(rand)]
//! use std::rand;
//! use std::rand::distributions::{IndependentSample, Range};
//!
@ -134,6 +137,7 @@
//! [Monty Hall Problem]: http://en.wikipedia.org/wiki/Monty_Hall_problem
//!
//! ```
//! # #![feature(rand)]
//! use std::rand;
//! use std::rand::Rng;
//! use std::rand::distributions::{IndependentSample, Range};
@ -384,6 +388,7 @@ impl Rng for ThreadRng {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand;
///
/// let x: u8 = rand::random();
@ -400,6 +405,7 @@ impl Rng for ThreadRng {
/// Caching the thread local random number generator:
///
/// ```
/// # #![feature(rand)]
/// use std::rand;
/// use std::rand::Rng;
///
@ -427,6 +433,7 @@ pub fn random<T: Rand>() -> T {
/// # Examples
///
/// ```
/// # #![feature(rand)]
/// use std::rand::{thread_rng, sample};
///
/// let mut rng = thread_rng();

View File

@ -24,6 +24,7 @@ use result::Result::{Ok, Err};
/// # Examples
///
/// ```
/// # #![feature(rand, old_io)]
/// use std::rand::{reader, Rng};
/// use std::old_io::MemReader;
///

View File

@ -69,6 +69,7 @@ pub struct Condvar { inner: Box<StaticCondvar> }
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// use std::sync::{StaticCondvar, CONDVAR_INIT};
///
/// static CVAR: StaticCondvar = CONDVAR_INIT;

View File

@ -14,6 +14,7 @@
//! # Examples
//!
//! ```
//! # #![feature(std_misc)]
//! use std::sync::Future;
//!
//! // a fake, for now

View File

@ -119,6 +119,7 @@
//! after 10 seconds no matter what:
//!
//! ```no_run
//! # #![feature(std_misc, old_io)]
//! use std::sync::mpsc::channel;
//! use std::old_io::timer::Timer;
//! use std::time::Duration;
@ -143,6 +144,7 @@
//! has been inactive for 5 seconds:
//!
//! ```no_run
//! # #![feature(std_misc, old_io)]
//! use std::sync::mpsc::channel;
//! use std::old_io::timer::Timer;
//! use std::time::Duration;

View File

@ -27,6 +27,7 @@
//! # Examples
//!
//! ```rust
//! # #![feature(std_misc)]
//! use std::sync::mpsc::channel;
//!
//! let (tx1, rx1) = channel();
@ -119,6 +120,7 @@ impl Select {
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// use std::sync::mpsc::Select;
///
/// let select = Select::new();

View File

@ -85,6 +85,7 @@ use fmt;
/// To recover from a poisoned mutex:
///
/// ```
/// # #![feature(std_misc)]
/// use std::sync::{Arc, Mutex};
/// use std::thread;
///
@ -136,6 +137,7 @@ unsafe impl<T: Send> Sync for Mutex<T> { }
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// use std::sync::{StaticMutex, MUTEX_INIT};
///
/// static LOCK: StaticMutex = MUTEX_INIT;

View File

@ -77,6 +77,7 @@ unsafe impl<T: Send + Sync> Sync for RwLock<T> {}
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// use std::sync::{StaticRwLock, RW_LOCK_INIT};
///
/// static LOCK: StaticRwLock = RW_LOCK_INIT;

View File

@ -25,6 +25,7 @@ use sync::{Mutex, Condvar};
/// # Examples
///
/// ```
/// # #![feature(std_misc)]
/// use std::sync::Semaphore;
///
/// // Create a semaphore that represents 5 resources

Some files were not shown because too many files have changed in this diff Show More