rollup merge of #23598: brson/gate

Conflicts:
	src/compiletest/compiletest.rs
	src/libcollections/lib.rs
	src/librustc_back/lib.rs
	src/libserialize/lib.rs
	src/libstd/lib.rs
	src/libtest/lib.rs
	src/test/run-make/rustdoc-default-impl/foo.rs
	src/test/run-pass/env-home-dir.rs
This commit is contained in:
Alex Crichton 2015-03-23 15:13:15 -07:00
commit c608084ff5
1839 changed files with 4533 additions and 304 deletions

View File

@ -40,8 +40,8 @@ pub struct TestProps {
pub check_stdout: bool, pub check_stdout: bool,
// Don't force a --crate-type=dylib flag on the command line // Don't force a --crate-type=dylib flag on the command line
pub no_prefer_dynamic: bool, pub no_prefer_dynamic: bool,
// Don't run --pretty expanded when running pretty printing tests // Run --pretty expanded when running pretty printing tests
pub no_pretty_expanded: bool, pub pretty_expanded: bool,
// Which pretty mode are we testing with, default to 'normal' // Which pretty mode are we testing with, default to 'normal'
pub pretty_mode: String, pub pretty_mode: String,
// Only compare pretty output and don't try compiling // Only compare pretty output and don't try compiling
@ -62,7 +62,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
let mut force_host = false; let mut force_host = false;
let mut check_stdout = false; let mut check_stdout = false;
let mut no_prefer_dynamic = false; let mut no_prefer_dynamic = false;
let mut no_pretty_expanded = false; let mut pretty_expanded = false;
let mut pretty_mode = None; let mut pretty_mode = None;
let mut pretty_compare_only = false; let mut pretty_compare_only = false;
let mut forbid_output = Vec::new(); let mut forbid_output = Vec::new();
@ -96,8 +96,8 @@ pub fn load_props(testfile: &Path) -> TestProps {
no_prefer_dynamic = parse_no_prefer_dynamic(ln); no_prefer_dynamic = parse_no_prefer_dynamic(ln);
} }
if !no_pretty_expanded { if !pretty_expanded {
no_pretty_expanded = parse_no_pretty_expanded(ln); pretty_expanded = parse_pretty_expanded(ln);
} }
if pretty_mode.is_none() { if pretty_mode.is_none() {
@ -152,7 +152,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
force_host: force_host, force_host: force_host,
check_stdout: check_stdout, check_stdout: check_stdout,
no_prefer_dynamic: no_prefer_dynamic, no_prefer_dynamic: no_prefer_dynamic,
no_pretty_expanded: no_pretty_expanded, pretty_expanded: pretty_expanded,
pretty_mode: pretty_mode.unwrap_or("normal".to_string()), pretty_mode: pretty_mode.unwrap_or("normal".to_string()),
pretty_compare_only: pretty_compare_only, pretty_compare_only: pretty_compare_only,
forbid_output: forbid_output, forbid_output: forbid_output,
@ -295,8 +295,8 @@ fn parse_no_prefer_dynamic(line: &str) -> bool {
parse_name_directive(line, "no-prefer-dynamic") parse_name_directive(line, "no-prefer-dynamic")
} }
fn parse_no_pretty_expanded(line: &str) -> bool { fn parse_pretty_expanded(line: &str) -> bool {
parse_name_directive(line, "no-pretty-expanded") parse_name_directive(line, "pretty-expanded")
} }
fn parse_pretty_mode(line: &str) -> Option<String> { fn parse_pretty_mode(line: &str) -> Option<String> {
@ -340,7 +340,8 @@ fn parse_pp_exact(line: &str, testfile: &Path) -> Option<PathBuf> {
} }
fn parse_name_directive(line: &str, directive: &str) -> bool { fn parse_name_directive(line: &str, directive: &str) -> bool {
line.contains(directive) // This 'no-' rule is a quick hack to allow pretty-expanded and no-pretty-expanded to coexist
line.contains(directive) && !line.contains(&("no-".to_string() + directive))
} }
pub fn parse_name_value_directive(line: &str, directive: &str) pub fn parse_name_value_directive(line: &str, directive: &str)

View File

@ -245,7 +245,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
if !proc_res.status.success() { if !proc_res.status.success() {
fatal_proc_rec("pretty-printed source does not typecheck", &proc_res); fatal_proc_rec("pretty-printed source does not typecheck", &proc_res);
} }
if props.no_pretty_expanded { return } if !props.pretty_expanded { return }
// additionally, run `--pretty expanded` and try to build it. // additionally, run `--pretty expanded` and try to build it.
let proc_res = print_source(config, props, testfile, srcs[round].clone(), "expanded"); let proc_res = print_source(config, props, testfile, srcs[round].clone(), "expanded");

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 containing module. Attributes on the anonymous crate module define important
metadata that influences the behavior of the compiler. metadata that influences the behavior of the compiler.
```{.rust} ```no_run
# #![allow(unused_attribute)]
// Crate name // Crate name
#![crate_name = "projx"] #![crate_name = "projx"]
@ -1020,6 +1019,7 @@ Use declarations support a number of convenient shortcuts:
An example of `use` declarations: An example of `use` declarations:
``` ```
# #![feature(core)]
use std::iter::range_step; use std::iter::range_step;
use std::option::Option::{Some, None}; use std::option::Option::{Some, None};
use std::collections::hash_map::{self, HashMap}; use std::collections::hash_map::{self, HashMap};
@ -1080,6 +1080,7 @@ declarations.
An example of what will and will not work for `use` items: An example of what will and will not work for `use` items:
``` ```
# #![feature(core)]
# #![allow(unused_imports)] # #![allow(unused_imports)]
use foo::core::iter; // good: foo is at the root of the crate 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 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. terminated by a semicolon.
``` ```
# #![feature(libc)]
extern crate libc; extern crate libc;
use libc::{c_char, FILE}; 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()`: finished. If we didn't want this behaviour, we could use `thread::spawn()`:
``` ```
# #![feature(old_io, std_misc)]
use std::thread; use std::thread;
use std::old_io::timer; use std::old_io::timer;
use std::time::Duration; 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: languages. It will not compile:
```ignore ```ignore
# #![feature(old_io, std_misc)]
use std::thread; use std::thread;
use std::old_io::timer; use std::old_io::timer;
use std::time::Duration; 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: but for a different reason:
```ignore ```ignore
# #![feature(old_io, std_misc)]
use std::thread; use std::thread;
use std::old_io::timer; use std::old_io::timer;
use std::time::Duration; 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: 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::sync::{Arc, Mutex};
use std::thread; use std::thread;
use std::old_io::timer; 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: thread more closely:
``` ```
# #![feature(old_io, std_misc)]
# use std::sync::{Arc, Mutex}; # use std::sync::{Arc, Mutex};
# use std::thread; # use std::thread;
# use std::old_io::timer; # use std::old_io::timer;

View File

@ -237,14 +237,17 @@ fn main() {
} }
``` ```
Here's the full algorithm: Here's the full algorithm rustdoc uses to postprocess examples:
1. Given a code block, if it does not contain `fn main()`, it is wrapped in 1. Any leading `#![foo]` attributes are left intact as crate attributes.
`fn main() { your_code }` 2. Some common `allow` attributes are inserted, including
2. Given that result, if it contains no `extern crate` directives but it also `unused_variables`, `unused_assignments`, `unused_mut`,
contains the name of the crate being tested, then `extern crate <name>` is `unused_attributes`, and `dead_code`. Small examples often trigger
injected at the top. these lints.
3. Some common allow attributes are added for documentation examples at the top. 3. If the example does not contain `extern crate`, then `extern crate
<mycrate>;` is inserted.
2. Finally, if the example does not contain `fn main`, the remainder of the
text is wrapped in `fn main() { your_code }`
Sometimes, this isn't enough, though. For example, all of these code samples Sometimes, this isn't enough, though. For example, all of these code samples
with `///` we've been talking about? The raw text: with `///` we've been talking about? The raw text:

View File

@ -12,6 +12,7 @@ The following is a minimal example of calling a foreign function which will
compile if snappy is installed: compile if snappy is installed:
```no_run ```no_run
# #![feature(libc)]
extern crate libc; extern crate libc;
use libc::size_t; 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: The `extern` block can be extended to cover the entire snappy API:
```no_run ```no_run
# #![feature(libc)]
extern crate libc; extern crate libc;
use libc::{c_int, size_t}; 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. the allocated memory. The length is less than or equal to the capacity.
``` ```
# #![feature(libc)]
# extern crate libc; # extern crate libc;
# use libc::{c_int, size_t}; # use libc::{c_int, size_t};
# unsafe fn snappy_validate_compressed_buffer(_: *const u8, _: size_t) -> c_int { 0 } # 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. the true length after compression for setting the length.
``` ```
# #![feature(libc)]
# extern crate libc; # extern crate libc;
# use libc::{size_t, c_int}; # use libc::{size_t, c_int};
# unsafe fn snappy_compress(a: *const u8, b: size_t, c: *mut u8, # 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. format and `snappy_uncompressed_length` will retrieve the exact buffer size required.
``` ```
# #![feature(libc)]
# extern crate libc; # extern crate libc;
# use libc::{size_t, c_int}; # use libc::{size_t, c_int};
# unsafe fn snappy_uncompress(compressed: *const u8, # 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: blocks with the `static` keyword:
```no_run ```no_run
# #![feature(libc)]
extern crate libc; extern crate libc;
#[link(name = "readline")] #[link(name = "readline")]
@ -426,6 +432,7 @@ interface. To do this, statics can be declared with `mut` so we can mutate
them. them.
```no_run ```no_run
# #![feature(libc)]
extern crate libc; extern crate libc;
use std::ffi::CString; 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: conventions. Rust provides a way to tell the compiler which convention to use:
``` ```
# #![feature(libc)]
extern crate libc; extern crate libc;
#[cfg(all(target_os = "win32", target_arch = "x86"))] #[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`: advanced iterators, including ones that are infinite. Like `count`:
```rust ```rust
# #![feature(core)]
std::iter::count(1, 5); 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()`: iterator from before, `count()`:
```rust ```rust
# #![feature(core)]
for i in std::iter::count(1, 5).take(5) { for i in std::iter::count(1, 5).take(5) {
println!("{}", i); 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: Here's how it works:
```{rust} ```{rust}
# #![feature(core)]
struct Circle { struct Circle {
x: f64, x: f64,
y: 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`. can do it by returning `self`.
``` ```
# #![feature(core)]
struct Circle { struct Circle {
x: f64, x: f64,
y: 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: the builder pattern instead. It looks like this:
``` ```
# #![feature(core)]
struct Circle { struct Circle {
x: f64, x: f64,
y: f64, y: f64,

View File

@ -177,6 +177,7 @@ Rust provides iterators for each of these situations:
Usually, the `graphemes()` method on `&str` is what you want: Usually, the `graphemes()` method on `&str` is what you want:
``` ```
# #![feature(unicode)]
let s = "u͔n͈̰̎i̙̮͚̦c͚̉o̼̩̰͗d͔̆̓ͥé"; let s = "u͔n͈̰̎i̙̮͚̦c͚̉o̼̩̰͗d͔̆̓ͥé";
for l in s.graphemes(true) { 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: and then prints it back out:
```{rust,ignore} ```{rust,ignore}
fn main() { corefn main() {
println!("Type something!"); println!("Type something!");
let input = std::old_io::stdin().read_line().ok().expect("Failed to read line"); 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: the `use` statement to import it in:
```{rust} ```{rust}
# #![feature(old_io)]
use std::old_io::stdin; use std::old_io::stdin;
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: to import the module, and only use one level of qualification:
```{rust} ```{rust}
# #![feature(old_io)]
use std::old_io; use std::old_io;
old_io::stdin(); 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. argument as used.
```rust ```rust
# #![feature(test)]
extern crate test; extern crate test;
# fn main() { # fn main() {

View File

@ -4,6 +4,7 @@ Do you remember the `impl` keyword, used to call a function with method
syntax? syntax?
```{rust} ```{rust}
# #![feature(core)]
struct Circle { struct Circle {
x: f64, x: f64,
y: 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: signature, then implement the trait for that struct. Like this:
```{rust} ```{rust}
# #![feature(core)]
struct Circle { struct Circle {
x: f64, x: f64,
y: f64, y: f64,
@ -84,6 +86,7 @@ which implements `HasArea` will have an `.area()` method.
Here's an extended example of how this works: Here's an extended example of how this works:
```{rust} ```{rust}
# #![feature(core)]
trait HasArea { trait HasArea {
fn area(&self) -> f64; 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: everything is fine:
```{rust} ```{rust}
# #![feature(core)]
use shapes::HasArea; use shapes::HasArea;
mod shapes { mod shapes {
@ -408,6 +412,7 @@ but instead, we found a floating-point variable. We need a different bound. `Flo
to the rescue: to the rescue:
``` ```
# #![feature(std_misc)]
use std::num::Float; use std::num::Float;
fn inverse<T: Float>(x: T) -> Result<T, String> { 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: works just fine:
``` ```
# #![feature(std_misc)]
# use std::num::Float; # use std::num::Float;
# fn inverse<T: Float>(x: T) -> Result<T, String> { # fn inverse<T: Float>(x: T) -> Result<T, String> {
# if x == Float::zero() { return Err("x cannot be zero!".to_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. reimplementation is as safe as the `Box` type.
``` ```
# #![feature(libc)]
#![feature(unsafe_destructor)] #![feature(unsafe_destructor)]
extern crate libc; extern crate libc;
@ -443,6 +444,7 @@ The function marked `#[start]` is passed the command line parameters
in the same format as C: in the same format as C:
``` ```
# #![feature(libc)]
#![feature(lang_items, start, no_std)] #![feature(lang_items, start, no_std)]
#![no_std] #![no_std]
@ -470,6 +472,7 @@ correct ABI and the correct name, which requires overriding the
compiler's name mangling too: compiler's name mangling too:
```ignore ```ignore
# #![feature(libc)]
#![feature(no_std)] #![feature(no_std)]
#![no_std] #![no_std]
#![no_main] #![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. vectors provided from C, using idiomatic Rust practices.
``` ```
# #![feature(libc, core)]
#![feature(lang_items, start, no_std)] #![feature(lang_items, start, no_std)]
#![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`: sugar for dynamic allocations via `malloc` and `free`:
``` ```
# #![feature(libc)]
#![feature(lang_items, box_syntax, start, no_std)] #![feature(lang_items, box_syntax, start, no_std)]
#![no_std] #![no_std]

View File

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

View File

@ -65,6 +65,7 @@ use core::raw::TraitObject;
/// The following two examples are equivalent: /// The following two examples are equivalent:
/// ///
/// ``` /// ```
/// # #![feature(alloc)]
/// #![feature(box_syntax)] /// #![feature(box_syntax)]
/// use std::boxed::HEAP; /// use std::boxed::HEAP;
/// ///
@ -135,6 +136,7 @@ impl<T : ?Sized> Box<T> {
/// ///
/// # Examples /// # Examples
/// ``` /// ```
/// # #![feature(alloc)]
/// use std::boxed; /// use std::boxed;
/// ///
/// let seventeen = Box::new(17u32); /// let seventeen = Box::new(17u32);
@ -178,6 +180,7 @@ impl<T: Clone> Clone for Box<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(alloc, core)]
/// let x = Box::new(5); /// let x = Box::new(5);
/// let mut y = Box::new(10); /// 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", #![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_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")] html_root_url = "http://doc.rust-lang.org/nightly/")]
#![doc(test(no_crate_inject))]
#![feature(no_std)] #![feature(no_std)]
#![no_std] #![no_std]

View File

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

View File

@ -216,6 +216,7 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BinaryHeap; /// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from_vec(vec![9, 1, 2, 7, 3, 2]); /// let heap = BinaryHeap::from_vec(vec![9, 1, 2, 7, 3, 2]);
/// ``` /// ```
@ -235,6 +236,7 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BinaryHeap; /// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]); /// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]);
/// ///
@ -255,6 +257,7 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BinaryHeap; /// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]); /// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]);
/// ///
@ -360,6 +363,7 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BinaryHeap; /// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::from_vec(vec![1, 3]); /// let mut heap = BinaryHeap::from_vec(vec![1, 3]);
/// ///
@ -405,6 +409,7 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BinaryHeap; /// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::new(); /// let mut heap = BinaryHeap::new();
/// heap.push(1); /// heap.push(1);
@ -436,6 +441,7 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BinaryHeap; /// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::new(); /// let mut heap = BinaryHeap::new();
/// ///
@ -461,6 +467,7 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BinaryHeap; /// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4, 5, 6, 7]); /// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4, 5, 6, 7]);
/// let vec = heap.into_vec(); /// let vec = heap.into_vec();
@ -478,6 +485,7 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BinaryHeap; /// use std::collections::BinaryHeap;
/// ///
/// let mut heap = BinaryHeap::from_vec(vec![1, 2, 4, 5, 7]); /// 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 //! [sieve]: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
//! //!
//! ``` //! ```
//! # #![feature(collections, core)]
//! use std::collections::{BitSet, BitVec}; //! use std::collections::{BitSet, BitVec};
//! use std::num::Float; //! use std::num::Float;
//! use std::iter; //! use std::iter;
@ -134,6 +135,7 @@ static FALSE: bool = false;
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let mut bv = BitVec::from_elem(10, false); /// let mut bv = BitVec::from_elem(10, false);
@ -262,6 +264,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// let mut bv = BitVec::new(); /// let mut bv = BitVec::new();
/// ``` /// ```
@ -276,6 +279,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let mut bv = BitVec::from_elem(10, false); /// let mut bv = BitVec::from_elem(10, false);
@ -316,6 +320,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let bv = BitVec::from_bytes(&[0b10100000, 0b00010010]); /// let bv = BitVec::from_bytes(&[0b10100000, 0b00010010]);
@ -358,6 +363,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let bv = BitVec::from_fn(5, |i| { i % 2 == 0 }); /// let bv = BitVec::from_fn(5, |i| { i % 2 == 0 });
@ -376,6 +382,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let bv = BitVec::from_bytes(&[0b01100000]); /// let bv = BitVec::from_bytes(&[0b01100000]);
@ -408,6 +415,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let mut bv = BitVec::from_elem(5, false); /// let mut bv = BitVec::from_elem(5, false);
@ -432,6 +440,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let before = 0b01100000; /// let before = 0b01100000;
@ -452,6 +461,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let before = 0b01100000; /// let before = 0b01100000;
@ -480,6 +490,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let a = 0b01100100; /// let a = 0b01100100;
@ -510,6 +521,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let a = 0b01100100; /// let a = 0b01100100;
@ -540,6 +552,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let a = 0b01100100; /// let a = 0b01100100;
@ -569,6 +582,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let mut bv = BitVec::from_elem(5, true); /// let mut bv = BitVec::from_elem(5, true);
@ -593,6 +607,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let bv = BitVec::from_bytes(&[0b01110100, 0b10010010]); /// let bv = BitVec::from_bytes(&[0b01110100, 0b10010010]);
@ -609,6 +624,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let mut bv = BitVec::from_elem(10, false); /// let mut bv = BitVec::from_elem(10, false);
@ -626,6 +642,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let mut bv = BitVec::from_elem(10, false); /// let mut bv = BitVec::from_elem(10, false);
@ -647,6 +664,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let mut bv = BitVec::from_elem(3, true); /// let mut bv = BitVec::from_elem(3, true);
@ -694,6 +712,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let bv = BitVec::from_bytes(&[0b10100000]); /// let bv = BitVec::from_bytes(&[0b10100000]);
@ -714,6 +733,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let mut bv = BitVec::from_bytes(&[0b01001011]); /// let mut bv = BitVec::from_bytes(&[0b01001011]);
@ -740,6 +760,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let mut bv = BitVec::from_elem(3, false); /// let mut bv = BitVec::from_elem(3, false);
@ -770,6 +791,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let mut bv = BitVec::from_elem(3, false); /// let mut bv = BitVec::from_elem(3, false);
@ -792,6 +814,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let mut bv = BitVec::new(); /// let mut bv = BitVec::new();
@ -813,6 +836,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let mut bv = BitVec::from_bytes(&[0b01001011]); /// let mut bv = BitVec::from_bytes(&[0b01001011]);
@ -863,6 +887,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let mut bv = BitVec::from_bytes(&[0b01001001]); /// let mut bv = BitVec::from_bytes(&[0b01001001]);
@ -893,6 +918,7 @@ impl BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitVec; /// use std::collections::BitVec;
/// ///
/// let mut bv = BitVec::new(); /// let mut bv = BitVec::new();
@ -1103,6 +1129,7 @@ impl<'a> IntoIterator for &'a BitVec {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::{BitSet, BitVec}; /// use std::collections::{BitSet, BitVec};
/// ///
/// // It's a regular set /// // It's a regular set
@ -1199,6 +1226,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitSet; /// use std::collections::BitSet;
/// ///
/// let mut s = BitSet::new(); /// let mut s = BitSet::new();
@ -1215,6 +1243,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitSet; /// use std::collections::BitSet;
/// ///
/// let mut s = BitSet::with_capacity(100); /// let mut s = BitSet::with_capacity(100);
@ -1232,6 +1261,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::{BitVec, BitSet}; /// use std::collections::{BitVec, BitSet};
/// ///
/// let bv = BitVec::from_bytes(&[0b01100000]); /// let bv = BitVec::from_bytes(&[0b01100000]);
@ -1261,6 +1291,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitSet; /// use std::collections::BitSet;
/// ///
/// let mut s = BitSet::with_capacity(100); /// let mut s = BitSet::with_capacity(100);
@ -1282,6 +1313,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitSet; /// use std::collections::BitSet;
/// ///
/// let mut s = BitSet::new(); /// let mut s = BitSet::new();
@ -1308,6 +1340,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitSet; /// use std::collections::BitSet;
/// ///
/// let mut s = BitSet::new(); /// let mut s = BitSet::new();
@ -1328,6 +1361,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitSet; /// use std::collections::BitSet;
/// ///
/// let mut s = BitSet::new(); /// let mut s = BitSet::new();
@ -1348,6 +1382,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitSet; /// use std::collections::BitSet;
/// ///
/// let mut s = BitSet::new(); /// let mut s = BitSet::new();
@ -1394,6 +1429,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BitSet; /// use std::collections::BitSet;
/// ///
/// let mut s = BitSet::new(); /// let mut s = BitSet::new();
@ -1426,6 +1462,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::{BitVec, BitSet}; /// use std::collections::{BitVec, BitSet};
/// ///
/// let s = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01001010])); /// let s = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01001010]));
@ -1447,6 +1484,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::{BitVec, BitSet}; /// use std::collections::{BitVec, BitSet};
/// ///
/// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000])); /// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000]));
@ -1477,6 +1515,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::{BitVec, BitSet}; /// use std::collections::{BitVec, BitSet};
/// ///
/// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000])); /// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000]));
@ -1507,6 +1546,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::{BitSet, BitVec}; /// use std::collections::{BitSet, BitVec};
/// ///
/// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000])); /// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000]));
@ -1545,6 +1585,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::{BitSet, BitVec}; /// use std::collections::{BitSet, BitVec};
/// ///
/// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000])); /// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000]));
@ -1574,6 +1615,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::{BitSet, BitVec}; /// use std::collections::{BitSet, BitVec};
/// ///
/// let a = 0b01101000; /// let a = 0b01101000;
@ -1597,6 +1639,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::{BitSet, BitVec}; /// use std::collections::{BitSet, BitVec};
/// ///
/// let a = 0b01101000; /// let a = 0b01101000;
@ -1621,6 +1664,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::{BitSet, BitVec}; /// use std::collections::{BitSet, BitVec};
/// ///
/// let a = 0b01101000; /// let a = 0b01101000;
@ -1653,6 +1697,7 @@ impl BitSet {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::{BitSet, BitVec}; /// use std::collections::{BitSet, BitVec};
/// ///
/// let a = 0b01101000; /// let a = 0b01101000;

View File

@ -1297,6 +1297,7 @@ impl<K, V> BTreeMap<K, V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::collections::BTreeMap; /// use std::collections::BTreeMap;
/// ///
/// let mut a = BTreeMap::new(); /// let mut a = BTreeMap::new();
@ -1319,6 +1320,7 @@ impl<K, V> BTreeMap<K, V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::collections::BTreeMap; /// use std::collections::BTreeMap;
/// ///
/// let mut a = BTreeMap::new(); /// let mut a = BTreeMap::new();
@ -1506,6 +1508,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BTreeMap; /// use std::collections::BTreeMap;
/// use std::collections::Bound::{Included, Unbounded}; /// use std::collections::Bound::{Included, Unbounded};
/// ///
@ -1532,6 +1535,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BTreeMap; /// use std::collections::BTreeMap;
/// use std::collections::Bound::{Included, Excluded}; /// use std::collections::Bound::{Included, Excluded};
/// ///
@ -1557,6 +1561,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::BTreeMap; /// use std::collections::BTreeMap;
/// use std::collections::btree_map::Entry; /// use std::collections::btree_map::Entry;
/// ///

View File

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

View File

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

View File

@ -22,6 +22,7 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/", html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")] html_playground_url = "http://play.rust-lang.org/")]
#![doc(test(no_crate_inject))]
#![feature(alloc)] #![feature(alloc)]
#![feature(box_syntax)] #![feature(box_syntax)]
@ -37,7 +38,7 @@
#![feature(step_by)] #![feature(step_by)]
#![feature(str_char)] #![feature(str_char)]
#![feature(convert)] #![feature(convert)]
#![cfg_attr(test, feature(rand, rustc_private, test))] #![cfg_attr(test, feature(rand, rustc_private, test, hash, collections))]
#![cfg_attr(test, allow(deprecated))] // rand #![cfg_attr(test, allow(deprecated))] // rand
#![feature(no_std)] #![feature(no_std)]

View File

@ -235,6 +235,7 @@ impl<T> LinkedList<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::LinkedList; /// use std::collections::LinkedList;
/// ///
/// let mut a = LinkedList::new(); /// let mut a = LinkedList::new();
@ -483,6 +484,7 @@ impl<T> LinkedList<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::LinkedList; /// use std::collections::LinkedList;
/// ///
/// let mut dl = LinkedList::new(); /// let mut dl = LinkedList::new();
@ -530,6 +532,7 @@ impl<T> LinkedList<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::LinkedList; /// use std::collections::LinkedList;
/// ///
/// let mut d = LinkedList::new(); /// let mut d = LinkedList::new();
@ -548,6 +551,7 @@ impl<T> LinkedList<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::LinkedList; /// use std::collections::LinkedList;
/// ///
/// let mut d = LinkedList::new(); /// let mut d = LinkedList::new();
@ -573,6 +577,7 @@ impl<T> LinkedList<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::LinkedList; /// use std::collections::LinkedList;
/// ///
/// let mut d = LinkedList::new(); /// let mut d = LinkedList::new();
@ -765,6 +770,7 @@ impl<'a, A> IterMut<'a, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::LinkedList; /// use std::collections::LinkedList;
/// ///
/// let mut list: LinkedList<_> = vec![1, 3, 4].into_iter().collect(); /// let mut list: LinkedList<_> = vec![1, 3, 4].into_iter().collect();
@ -792,6 +798,7 @@ impl<'a, A> IterMut<'a, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::LinkedList; /// use std::collections::LinkedList;
/// ///
/// let mut list: LinkedList<_> = vec![1, 2, 3].into_iter().collect(); /// 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. //! Slices are a view into a block of memory represented as a pointer and a length.
//! //!
//! ```rust //! ```rust
//! # #![feature(core)]
//! // slicing a Vec //! // slicing a Vec
//! let vec = vec!(1, 2, 3); //! let vec = vec!(1, 2, 3);
//! let int_slice = vec.as_slice(); //! let int_slice = vec.as_slice();
@ -271,6 +272,7 @@ impl<T> [T] {
/// # Examples /// # Examples
/// ///
/// ```rust /// ```rust
/// # #![feature(collections)]
/// let mut a = [1, 2, 3, 4, 5]; /// let mut a = [1, 2, 3, 4, 5];
/// let b = vec![6, 7, 8]; /// let b = vec![6, 7, 8];
/// let num_moved = a.move_from(b, 0, 3); /// let num_moved = a.move_from(b, 0, 3);
@ -561,6 +563,7 @@ impl<T> [T] {
/// found; the fourth could match any position in `[1,4]`. /// found; the fourth could match any position in `[1,4]`.
/// ///
/// ```rust /// ```rust
/// # #![feature(core)]
/// let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]; /// let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
/// let s = s.as_slice(); /// let s = s.as_slice();
/// ///
@ -843,6 +846,7 @@ impl<T> [T] {
/// # Examples /// # Examples
/// ///
/// ```rust /// ```rust
/// # #![feature(collections)]
/// let v = [1, 2, 3]; /// let v = [1, 2, 3];
/// let mut perms = v.permutations(); /// let mut perms = v.permutations();
/// ///
@ -854,6 +858,7 @@ impl<T> [T] {
/// Iterating through permutations one by one. /// Iterating through permutations one by one.
/// ///
/// ```rust /// ```rust
/// # #![feature(collections)]
/// let v = [1, 2, 3]; /// let v = [1, 2, 3];
/// let mut perms = v.permutations(); /// let mut perms = v.permutations();
/// ///
@ -875,6 +880,7 @@ impl<T> [T] {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// # #![feature(collections)]
/// let mut dst = [0, 0, 0]; /// let mut dst = [0, 0, 0];
/// let src = [1, 2]; /// let src = [1, 2];
/// ///
@ -922,6 +928,7 @@ impl<T> [T] {
/// found; the fourth could match any position in `[1,4]`. /// found; the fourth could match any position in `[1,4]`.
/// ///
/// ```rust /// ```rust
/// # #![feature(core)]
/// let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]; /// let s = [0, 1, 1, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
/// let s = s.as_slice(); /// let s = s.as_slice();
/// ///
@ -951,6 +958,7 @@ impl<T> [T] {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// # #![feature(collections)]
/// let v: &mut [_] = &mut [0, 1, 2]; /// let v: &mut [_] = &mut [0, 1, 2];
/// v.next_permutation(); /// v.next_permutation();
/// let b: &mut [_] = &mut [0, 2, 1]; /// let b: &mut [_] = &mut [0, 2, 1];
@ -973,6 +981,7 @@ impl<T> [T] {
/// # Example /// # Example
/// ///
/// ```rust /// ```rust
/// # #![feature(collections)]
/// let v: &mut [_] = &mut [1, 0, 2]; /// let v: &mut [_] = &mut [1, 0, 2];
/// v.prev_permutation(); /// v.prev_permutation();
/// let b: &mut [_] = &mut [0, 2, 1]; /// let b: &mut [_] = &mut [0, 2, 1];

View File

@ -544,6 +544,7 @@ impl str {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// assert!("hello".contains_char('e')); /// assert!("hello".contains_char('e'));
/// ///
/// assert!(!"hello".contains_char('z')); /// assert!(!"hello".contains_char('z'));
@ -762,6 +763,7 @@ impl str {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// let v: Vec<(usize, usize)> = "abcXXXabcYYYabc".match_indices("abc").collect(); /// let v: Vec<(usize, usize)> = "abcXXXabcYYYabc".match_indices("abc").collect();
/// assert_eq!(v, [(0,3), (6,9), (12,15)]); /// assert_eq!(v, [(0,3), (6,9), (12,15)]);
/// ///
@ -784,6 +786,7 @@ impl str {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// let v: Vec<&str> = "abcXXXabcYYYabc".split_str("abc").collect(); /// let v: Vec<&str> = "abcXXXabcYYYabc".split_str("abc").collect();
/// assert_eq!(v, ["", "XXX", "YYY", ""]); /// assert_eq!(v, ["", "XXX", "YYY", ""]);
/// ///
@ -892,6 +895,7 @@ impl str {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// let s = "Löwe 老虎 Léopard"; /// let s = "Löwe 老虎 Léopard";
/// ///
/// assert_eq!(s.slice_chars(0, 4), "Löwe"); /// assert_eq!(s.slice_chars(0, 4), "Löwe");
@ -1042,6 +1046,7 @@ impl str {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(str_char)]
/// let s = "Löwe 老虎 Léopard"; /// let s = "Löwe 老虎 Léopard";
/// assert!(s.is_char_boundary(0)); /// assert!(s.is_char_boundary(0));
/// // start of `老` /// // start of `老`
@ -1078,6 +1083,7 @@ impl str {
/// done by `.chars()` or `.char_indices()`. /// done by `.chars()` or `.char_indices()`.
/// ///
/// ``` /// ```
/// # #![feature(str_char, core)]
/// use std::str::CharRange; /// use std::str::CharRange;
/// ///
/// let s = "中华Việt Nam"; /// let s = "中华Việt Nam";
@ -1128,6 +1134,7 @@ impl str {
/// done by `.chars().rev()` or `.char_indices()`. /// done by `.chars().rev()` or `.char_indices()`.
/// ///
/// ``` /// ```
/// # #![feature(str_char, core)]
/// use std::str::CharRange; /// use std::str::CharRange;
/// ///
/// let s = "中华Việt Nam"; /// let s = "中华Việt Nam";
@ -1171,6 +1178,7 @@ impl str {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(str_char)]
/// let s = "abπc"; /// let s = "abπc";
/// assert_eq!(s.char_at(1), 'b'); /// assert_eq!(s.char_at(1), 'b');
/// assert_eq!(s.char_at(2), 'π'); /// assert_eq!(s.char_at(2), 'π');
@ -1195,6 +1203,7 @@ impl str {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(str_char)]
/// let s = "abπc"; /// let s = "abπc";
/// assert_eq!(s.char_at_reverse(1), 'a'); /// assert_eq!(s.char_at_reverse(1), 'a');
/// assert_eq!(s.char_at_reverse(2), 'b'); /// assert_eq!(s.char_at_reverse(2), 'b');
@ -1309,6 +1318,7 @@ impl str {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// let s = "Löwe 老虎 Léopard"; /// let s = "Löwe 老虎 Léopard";
/// ///
/// assert_eq!(s.find_str("老虎 L"), Some(6)); /// assert_eq!(s.find_str("老虎 L"), Some(6));
@ -1330,6 +1340,7 @@ impl str {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(str_char)]
/// let s = "Löwe 老虎 Léopard"; /// let s = "Löwe 老虎 Léopard";
/// let (c, s1) = s.slice_shift_char().unwrap(); /// let (c, s1) = s.slice_shift_char().unwrap();
/// ///
@ -1358,6 +1369,7 @@ impl str {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// let string = "a\nb\nc"; /// let string = "a\nb\nc";
/// let lines: Vec<&str> = string.lines().collect(); /// let lines: Vec<&str> = string.lines().collect();
/// ///
@ -1457,6 +1469,7 @@ impl str {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(unicode, core)]
/// let gr1 = "a\u{310}e\u{301}o\u{308}\u{332}".graphemes(true).collect::<Vec<&str>>(); /// 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}"]; /// let b: &[_] = &["a\u{310}", "e\u{301}", "o\u{308}\u{332}"];
/// ///
@ -1479,6 +1492,7 @@ impl str {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(unicode, core)]
/// let gr_inds = "a̐éö̲\r\n".grapheme_indices(true).collect::<Vec<(usize, &str)>>(); /// let gr_inds = "a̐éö̲\r\n".grapheme_indices(true).collect::<Vec<(usize, &str)>>();
/// let b: &[_] = &[(0, "a̐"), (3, "é"), (6, "ö̲"), (11, "\r\n")]; /// let b: &[_] = &[(0, "a̐"), (3, "é"), (6, "ö̲"), (11, "\r\n")];
/// ///
@ -1498,6 +1512,7 @@ impl str {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(str_words)]
/// let some_words = " Mary had\ta little \n\t lamb"; /// let some_words = " Mary had\ta little \n\t lamb";
/// let v: Vec<&str> = some_words.words().collect(); /// let v: Vec<&str> = some_words.words().collect();
/// ///

View File

@ -91,6 +91,7 @@ impl String {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections, core)]
/// let s = String::from_str("hello"); /// let s = String::from_str("hello");
/// assert_eq!(s.as_slice(), "hello"); /// assert_eq!(s.as_slice(), "hello");
/// ``` /// ```
@ -123,6 +124,7 @@ impl String {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::str::Utf8Error; /// use std::str::Utf8Error;
/// ///
/// let hello_vec = vec![104, 101, 108, 108, 111]; /// let hello_vec = vec![104, 101, 108, 108, 111];
@ -351,6 +353,7 @@ impl String {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// let s = String::from_str("hello"); /// let s = String::from_str("hello");
/// let bytes = s.into_bytes(); /// let bytes = s.into_bytes();
/// assert_eq!(bytes, [104, 101, 108, 108, 111]); /// assert_eq!(bytes, [104, 101, 108, 108, 111]);
@ -366,6 +369,7 @@ impl String {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// let mut s = String::from_str("foo"); /// let mut s = String::from_str("foo");
/// s.push_str("bar"); /// s.push_str("bar");
/// assert_eq!(s, "foobar"); /// assert_eq!(s, "foobar");
@ -442,6 +446,7 @@ impl String {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// let mut s = String::from_str("foo"); /// let mut s = String::from_str("foo");
/// s.reserve(100); /// s.reserve(100);
/// assert!(s.capacity() >= 100); /// assert!(s.capacity() >= 100);
@ -459,6 +464,7 @@ impl String {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// let mut s = String::from_str("abc"); /// let mut s = String::from_str("abc");
/// s.push('1'); /// s.push('1');
/// s.push('2'); /// s.push('2');
@ -494,6 +500,7 @@ impl String {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// let s = String::from_str("hello"); /// let s = String::from_str("hello");
/// let b: &[_] = &[104, 101, 108, 108, 111]; /// let b: &[_] = &[104, 101, 108, 108, 111];
/// assert_eq!(s.as_bytes(), b); /// assert_eq!(s.as_bytes(), b);
@ -514,6 +521,7 @@ impl String {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// let mut s = String::from_str("hello"); /// let mut s = String::from_str("hello");
/// s.truncate(2); /// s.truncate(2);
/// assert_eq!(s, "he"); /// assert_eq!(s, "he");
@ -531,6 +539,7 @@ impl String {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// let mut s = String::from_str("foo"); /// let mut s = String::from_str("foo");
/// assert_eq!(s.pop(), Some('o')); /// assert_eq!(s.pop(), Some('o'));
/// assert_eq!(s.pop(), Some('o')); /// assert_eq!(s.pop(), Some('o'));
@ -568,6 +577,7 @@ impl String {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// let mut s = String::from_str("foo"); /// let mut s = String::from_str("foo");
/// assert_eq!(s.remove(0), 'f'); /// assert_eq!(s.remove(0), 'f');
/// assert_eq!(s.remove(1), 'o'); /// assert_eq!(s.remove(1), 'o');
@ -630,6 +640,7 @@ impl String {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// let mut s = String::from_str("hello"); /// let mut s = String::from_str("hello");
/// unsafe { /// unsafe {
/// let vec = s.as_mut_vec(); /// let vec = s.as_mut_vec();
@ -983,6 +994,7 @@ impl<'a> Deref for DerefString<'a> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::string::as_string; /// use std::string::as_string;
/// ///
/// fn string_consumer(s: String) { /// fn string_consumer(s: String) {

View File

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

View File

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

View File

@ -34,6 +34,7 @@ use vec::Vec;
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// ///
/// let mut months = VecMap::new(); /// let mut months = VecMap::new();
@ -134,6 +135,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// let mut map: VecMap<&str> = VecMap::new(); /// let mut map: VecMap<&str> = VecMap::new();
/// ``` /// ```
@ -146,6 +148,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// let mut map: VecMap<&str> = VecMap::with_capacity(10); /// let mut map: VecMap<&str> = VecMap::with_capacity(10);
/// ``` /// ```
@ -160,6 +163,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// let map: VecMap<String> = VecMap::with_capacity(10); /// let map: VecMap<String> = VecMap::with_capacity(10);
/// assert!(map.capacity() >= 10); /// assert!(map.capacity() >= 10);
@ -179,6 +183,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// let mut map: VecMap<&str> = VecMap::new(); /// let mut map: VecMap<&str> = VecMap::new();
/// map.reserve_len(10); /// map.reserve_len(10);
@ -203,6 +208,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// let mut map: VecMap<&str> = VecMap::new(); /// let mut map: VecMap<&str> = VecMap::new();
/// map.reserve_len_exact(10); /// map.reserve_len_exact(10);
@ -242,6 +248,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// ///
/// let mut map = VecMap::new(); /// let mut map = VecMap::new();
@ -270,6 +277,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// ///
/// let mut map = VecMap::new(); /// let mut map = VecMap::new();
@ -301,6 +309,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// ///
/// let mut map = VecMap::new(); /// let mut map = VecMap::new();
@ -327,6 +336,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// ///
/// let mut a = VecMap::new(); /// let mut a = VecMap::new();
@ -362,6 +372,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// ///
/// let mut a = VecMap::new(); /// let mut a = VecMap::new();
@ -418,6 +429,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// ///
/// let mut map = VecMap::new(); /// let mut map = VecMap::new();
@ -445,6 +457,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// ///
/// let mut a = VecMap::new(); /// let mut a = VecMap::new();
@ -462,6 +475,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// ///
/// let mut a = VecMap::new(); /// let mut a = VecMap::new();
@ -479,6 +493,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// ///
/// let mut a = VecMap::new(); /// let mut a = VecMap::new();
@ -494,6 +509,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// ///
/// let mut map = VecMap::new(); /// let mut map = VecMap::new();
@ -518,6 +534,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// ///
/// let mut map = VecMap::new(); /// let mut map = VecMap::new();
@ -536,6 +553,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// ///
/// let mut map = VecMap::new(); /// let mut map = VecMap::new();
@ -564,6 +582,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// ///
/// let mut map = VecMap::new(); /// let mut map = VecMap::new();
@ -589,6 +608,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// ///
/// let mut map = VecMap::new(); /// let mut map = VecMap::new();
@ -610,6 +630,7 @@ impl<V> VecMap<V> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(collections)]
/// use std::collections::VecMap; /// use std::collections::VecMap;
/// use std::collections::vec_map::Entry; /// use std::collections::vec_map::Entry;
/// ///

View File

@ -20,6 +20,7 @@
#![feature(unboxed_closures)] #![feature(unboxed_closures)]
#![feature(unicode)] #![feature(unicode)]
#![feature(unsafe_destructor)] #![feature(unsafe_destructor)]
#![cfg_attr(test, feature(str_char))]
#[macro_use] extern crate log; #[macro_use] extern crate log;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -262,6 +262,7 @@ extern "rust-intrinsic" {
/// A safe swap function: /// A safe swap function:
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::mem; /// use std::mem;
/// use std::ptr; /// use std::ptr;
/// ///
@ -301,6 +302,7 @@ extern "rust-intrinsic" {
/// Efficiently create a Rust vector from an unsafe buffer: /// Efficiently create a Rust vector from an unsafe buffer:
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::ptr; /// use std::ptr;
/// ///
/// unsafe fn from_buf_raw<T>(ptr: *const T, elts: uint) -> Vec<T> { /// 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 /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// let xs = [100, 200, 300]; /// let xs = [100, 200, 300];
/// let mut it = xs.iter().cloned().peekable(); /// let mut it = xs.iter().cloned().peekable();
/// assert_eq!(*it.peek().unwrap(), 100); /// assert_eq!(*it.peek().unwrap(), 100);
@ -465,6 +466,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// let xs = [2, 3]; /// let xs = [2, 3];
/// let ys = [0, 1, 0, 1, 2]; /// let ys = [0, 1, 0, 1, 2];
/// let it = xs.iter().flat_map(|&x| std::iter::count(0, 1).take(x)); /// let it = xs.iter().flat_map(|&x| std::iter::count(0, 1).take(x));
@ -521,6 +523,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::iter::AdditiveIterator; /// use std::iter::AdditiveIterator;
/// ///
/// let a = [1, 4, 2, 3, 8, 9, 6]; /// let a = [1, 4, 2, 3, 8, 9, 6];
@ -563,6 +566,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// let a = [1, 2, 3, 4, 5]; /// let a = [1, 2, 3, 4, 5];
/// let b: Vec<_> = a.iter().cloned().collect(); /// let b: Vec<_> = a.iter().cloned().collect();
/// assert_eq!(a, b); /// assert_eq!(a, b);
@ -579,6 +583,7 @@ pub trait IteratorExt: Iterator + Sized {
/// do not. /// do not.
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// let vec = vec![1, 2, 3, 4]; /// let vec = vec![1, 2, 3, 4];
/// let (even, odd): (Vec<_>, Vec<_>) = vec.into_iter().partition(|&n| n % 2 == 0); /// let (even, odd): (Vec<_>, Vec<_>) = vec.into_iter().partition(|&n| n % 2 == 0);
/// assert_eq!(even, [2, 4]); /// assert_eq!(even, [2, 4]);
@ -648,6 +653,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// let a = [1, 2, 3, 4, 5]; /// let a = [1, 2, 3, 4, 5];
/// let mut it = a.iter(); /// let mut it = a.iter();
/// assert!(it.any(|x| *x == 3)); /// assert!(it.any(|x| *x == 3));
@ -668,6 +674,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// let a = [1, 2, 3, 4, 5]; /// let a = [1, 2, 3, 4, 5];
/// let mut it = a.iter(); /// let mut it = a.iter();
/// assert_eq!(it.find(|&x| *x == 3).unwrap(), &3); /// assert_eq!(it.find(|&x| *x == 3).unwrap(), &3);
@ -690,6 +697,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// let a = [1, 2, 3, 4, 5]; /// let a = [1, 2, 3, 4, 5];
/// let mut it = a.iter(); /// let mut it = a.iter();
/// assert_eq!(it.position(|x| *x == 3).unwrap(), 2); /// assert_eq!(it.position(|x| *x == 3).unwrap(), 2);
@ -718,6 +726,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// let a = [1, 2, 2, 4, 5]; /// let a = [1, 2, 2, 4, 5];
/// let mut it = a.iter(); /// let mut it = a.iter();
/// assert_eq!(it.rposition(|x| *x == 2).unwrap(), 2); /// assert_eq!(it.rposition(|x| *x == 2).unwrap(), 2);
@ -795,6 +804,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::iter::MinMaxResult::{NoElements, OneElement, MinMax}; /// use std::iter::MinMaxResult::{NoElements, OneElement, MinMax};
/// ///
/// let a: [i32; 0] = []; /// let a: [i32; 0] = [];
@ -860,7 +870,8 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// use core::num::SignedInt; /// # #![feature(core)]
/// use std::num::SignedInt;
/// ///
/// let a = [-3, 0, 1, 5, -10]; /// let a = [-3, 0, 1, 5, -10];
/// assert_eq!(*a.iter().max_by(|x| x.abs()).unwrap(), -10); /// assert_eq!(*a.iter().max_by(|x| x.abs()).unwrap(), -10);
@ -890,7 +901,8 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// use core::num::SignedInt; /// # #![feature(core)]
/// use std::num::SignedInt;
/// ///
/// let a = [-3, 0, 1, 5, -10]; /// let a = [-3, 0, 1, 5, -10];
/// assert_eq!(*a.iter().min_by(|x| x.abs()).unwrap(), 0); /// assert_eq!(*a.iter().min_by(|x| x.abs()).unwrap(), 0);
@ -940,6 +952,7 @@ pub trait IteratorExt: Iterator + Sized {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// let a = [(1, 2), (3, 4)]; /// let a = [(1, 2), (3, 4)];
/// let (left, right): (Vec<_>, Vec<_>) = a.iter().cloned().unzip(); /// let (left, right): (Vec<_>, Vec<_>) = a.iter().cloned().unzip();
/// assert_eq!([1, 3], left); /// assert_eq!([1, 3], left);
@ -1146,6 +1159,7 @@ pub trait AdditiveIterator<A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::iter::AdditiveIterator; /// use std::iter::AdditiveIterator;
/// ///
/// let a = [1, 2, 3, 4, 5]; /// let a = [1, 2, 3, 4, 5];
@ -1188,6 +1202,7 @@ pub trait MultiplicativeIterator<A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::iter::{count, MultiplicativeIterator}; /// use std::iter::{count, MultiplicativeIterator};
/// ///
/// fn factorial(n: usize) -> usize { /// fn factorial(n: usize) -> usize {
@ -1248,6 +1263,7 @@ impl<T: Clone> MinMaxResult<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::iter::MinMaxResult::{self, NoElements, OneElement, MinMax}; /// use std::iter::MinMaxResult::{self, NoElements, OneElement, MinMax};
/// ///
/// let r: MinMaxResult<i32> = NoElements; /// 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. /// An iterator that yields sequential Fibonacci numbers, and stops on overflow.
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::iter::Unfold; /// use std::iter::Unfold;
/// use std::num::Int; // For `.checked_add()` /// use std::num::Int; // For `.checked_add()`
/// ///
@ -2693,6 +2710,7 @@ pub struct RangeStepInclusive<A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::iter::range_step_inclusive; /// use std::iter::range_step_inclusive;
/// ///
/// for i in range_step_inclusive(0, 10, 2) { /// 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_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/", html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")] html_playground_url = "http://play.rust-lang.org/")]
#![doc(test(no_crate_inject))]
#![feature(no_std)] #![feature(no_std)]
#![no_std] #![no_std]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -276,6 +276,7 @@ impl<T> Option<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// let mut x = Some("Diamonds"); /// let mut x = Some("Diamonds");
/// { /// {
/// let v = x.as_mut_slice(); /// let v = x.as_mut_slice();
@ -471,6 +472,7 @@ impl<T> Option<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// let x = Some("foo"); /// let x = Some("foo");
/// assert_eq!(x.ok_or(0), Ok("foo")); /// assert_eq!(x.ok_or(0), Ok("foo"));
/// ///
@ -492,6 +494,7 @@ impl<T> Option<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// let x = Some("foo"); /// let x = Some("foo");
/// assert_eq!(x.ok_or_else(|| 0), Ok("foo")); /// assert_eq!(x.ok_or_else(|| 0), Ok("foo"));
/// ///
@ -533,6 +536,7 @@ impl<T> Option<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// let mut x = Some(4); /// let mut x = Some(4);
/// match x.iter_mut().next() { /// match x.iter_mut().next() {
/// Some(&mut ref mut v) => *v = 42, /// 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. //! the raw pointer. It doesn't destroy `T` or deallocate any memory.
//! //!
//! ``` //! ```
//! # #![feature(alloc)]
//! use std::boxed; //! use std::boxed;
//! //!
//! unsafe { //! unsafe {
@ -70,6 +71,7 @@
//! ## 3. Get it from C. //! ## 3. Get it from C.
//! //!
//! ``` //! ```
//! # #![feature(libc)]
//! extern crate libc; //! extern crate libc;
//! //!
//! use std::mem; //! use std::mem;

View File

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

View File

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

View File

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

View File

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

View File

@ -24,6 +24,8 @@
#![feature(io)] #![feature(io)]
#![feature(collections)] #![feature(collections)]
#![feature(debug_builders)] #![feature(debug_builders)]
#![feature(unique)]
#![feature(step_by)]
#![allow(deprecated)] // rand #![allow(deprecated)] // rand
extern crate core; extern crate core;

View File

@ -28,6 +28,7 @@
#![feature(libc)] #![feature(libc)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(unique)] #![feature(unique)]
#![cfg_attr(test, feature(rustc_private, rand, collections))]
#[cfg(test)] #[macro_use] extern crate log; #[cfg(test)] #[macro_use] extern crate log;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -212,7 +212,7 @@ impl LintStore {
fn maybe_stage_features(&mut self, sess: &Session) { fn maybe_stage_features(&mut self, sess: &Session) {
let lvl = match sess.opts.unstable_features { let lvl = match sess.opts.unstable_features {
UnstableFeatures::Default => return, UnstableFeatures::Default => return,
UnstableFeatures::Disallow => Warn, UnstableFeatures::Disallow => Forbid,
UnstableFeatures::Cheat => Allow UnstableFeatures::Cheat => Allow
}; };
match self.by_name.get("unstable_features") { match self.by_name.get("unstable_features") {

View File

@ -26,7 +26,7 @@ use syntax::ast::{Item, Generics, StructField};
use syntax::ast_util::is_local; use syntax::ast_util::is_local;
use syntax::attr::{Stability, AttrMetaMethods}; use syntax::attr::{Stability, AttrMetaMethods};
use syntax::visit::{FnKind, Visitor}; use syntax::visit::{FnKind, Visitor};
use syntax::feature_gate::emit_feature_warn; use syntax::feature_gate::emit_feature_err;
use util::nodemap::{NodeMap, DefIdMap, FnvHashSet, FnvHashMap}; use util::nodemap::{NodeMap, DefIdMap, FnvHashSet, FnvHashMap};
use util::ppaux::Repr; use util::ppaux::Repr;
@ -237,7 +237,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
None => format!("use of unstable library feature '{}'", &feature) None => format!("use of unstable library feature '{}'", &feature)
}; };
emit_feature_warn(&self.tcx.sess.parse_sess.span_diagnostic, emit_feature_err(&self.tcx.sess.parse_sess.span_diagnostic,
&feature, span, &msg); &feature, span, &msg);
} }
} }

View File

@ -50,6 +50,7 @@
#![feature(path_relative_from)] #![feature(path_relative_from)]
#![feature(step_by)] #![feature(step_by)]
#![feature(convert)] #![feature(convert)]
#![cfg_attr(test, feature(test, rand))]
extern crate syntax; extern crate syntax;
extern crate serialize; extern crate serialize;

View File

@ -18,6 +18,7 @@
#![feature(no_std)] #![feature(no_std)]
#![no_std] #![no_std]
#![unstable(feature = "rustc_private")] #![unstable(feature = "rustc_private")]
#![cfg_attr(test, feature(hash))]
//! A typesafe bitmask flag generator. //! A typesafe bitmask flag generator.
@ -32,6 +33,7 @@
/// # Examples /// # Examples
/// ///
/// ```{.rust} /// ```{.rust}
/// # #![feature(rustc_private)]
/// #[macro_use] extern crate rustc_bitflags; /// #[macro_use] extern crate rustc_bitflags;
/// ///
/// bitflags! { /// bitflags! {
@ -58,6 +60,7 @@
/// The generated `struct`s can also be extended with type and trait implementations: /// The generated `struct`s can also be extended with type and trait implementations:
/// ///
/// ```{.rust} /// ```{.rust}
/// # #![feature(rustc_private)]
/// #[macro_use] extern crate rustc_bitflags; /// #[macro_use] extern crate rustc_bitflags;
/// ///
/// use std::fmt; /// use std::fmt;

View File

@ -230,7 +230,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
stripped_filtered_line(l).unwrap_or(l) stripped_filtered_line(l).unwrap_or(l)
}).collect::<Vec<&str>>().connect("\n"); }).collect::<Vec<&str>>().connect("\n");
let krate = krate.as_ref().map(|s| &**s); let krate = krate.as_ref().map(|s| &**s);
let test = test::maketest(&test, krate, false, false); let test = test::maketest(&test, krate, false, false, true);
s.push_str(&format!("<span class='rusttest'>{}</span>", Escape(&test))); s.push_str(&format!("<span class='rusttest'>{}</span>", Escape(&test)));
}); });
s.push_str(&highlight::highlight(&text, s.push_str(&highlight::highlight(&text,

View File

@ -52,6 +52,7 @@ extern crate rustc_back;
extern crate serialize; extern crate serialize;
extern crate syntax; extern crate syntax;
extern crate "test" as testing; extern crate "test" as testing;
extern crate unicode;
#[macro_use] extern crate log; #[macro_use] extern crate log;
extern crate "serialize" as rustc_serialize; // used by deriving extern crate "serialize" as rustc_serialize; // used by deriving

View File

@ -143,7 +143,7 @@ pub fn test(input: &str, libs: SearchPaths, externs: core::Externs,
mut test_args: Vec<String>) -> int { mut test_args: Vec<String>) -> int {
let input_str = load_or_return!(input, 1, 2); let input_str = load_or_return!(input, 1, 2);
let mut collector = Collector::new(input.to_string(), libs, externs, true); let mut collector = Collector::new(input.to_string(), libs, externs, true, false);
find_testable_code(&input_str, &mut collector); find_testable_code(&input_str, &mut collector);
test_args.insert(0, "rustdoctest".to_string()); test_args.insert(0, "rustdoctest".to_string());
testing::test_main(&test_args, collector.tests); testing::test_main(&test_args, collector.tests);

View File

@ -76,6 +76,8 @@ pub fn run(input: &str,
"rustdoc-test", None) "rustdoc-test", None)
.expect("phase_2_configure_and_expand aborted in rustdoc!"); .expect("phase_2_configure_and_expand aborted in rustdoc!");
let inject_crate = should_inject_crate(&krate);
let ctx = core::DocContext { let ctx = core::DocContext {
krate: &krate, krate: &krate,
maybe_typed: core::NotTyped(sess), maybe_typed: core::NotTyped(sess),
@ -100,7 +102,8 @@ pub fn run(input: &str,
let mut collector = Collector::new(krate.name.to_string(), let mut collector = Collector::new(krate.name.to_string(),
libs, libs,
externs, externs,
false); false,
inject_crate);
collector.fold_crate(krate); collector.fold_crate(krate);
test_args.insert(0, "rustdoctest".to_string()); test_args.insert(0, "rustdoctest".to_string());
@ -110,13 +113,42 @@ pub fn run(input: &str,
0 0
} }
// Look for #![doc(test(no_crate_inject))], used by crates in the std facade
fn should_inject_crate(krate: &::syntax::ast::Crate) -> bool {
use syntax::attr::AttrMetaMethods;
let mut inject_crate = true;
for attr in &krate.attrs {
if attr.check_name("doc") {
for list in attr.meta_item_list().into_iter() {
for attr in list {
if attr.check_name("test") {
for list in attr.meta_item_list().into_iter() {
for attr in list {
if attr.check_name("no_crate_inject") {
inject_crate = false;
}
}
}
}
}
}
}
}
return inject_crate;
}
#[allow(deprecated)] #[allow(deprecated)]
fn runtest(test: &str, cratename: &str, libs: SearchPaths, fn runtest(test: &str, cratename: &str, libs: SearchPaths,
externs: core::Externs, externs: core::Externs,
should_panic: bool, no_run: bool, as_test_harness: bool) { should_panic: bool, no_run: bool, as_test_harness: bool,
inject_crate: bool) {
// the test harness wants its own `main` & top level functions, so // the test harness wants its own `main` & top level functions, so
// never wrap the test in `fn main() { ... }` // never wrap the test in `fn main() { ... }`
let test = maketest(test, Some(cratename), true, as_test_harness); let test = maketest(test, Some(cratename), true, as_test_harness,
inject_crate);
let input = config::Input::Str(test.to_string()); let input = config::Input::Str(test.to_string());
let sessopts = config::Options { let sessopts = config::Options {
@ -218,8 +250,16 @@ fn runtest(test: &str, cratename: &str, libs: SearchPaths,
} }
} }
pub fn maketest(s: &str, cratename: Option<&str>, lints: bool, dont_insert_main: bool) -> String { pub fn maketest(s: &str, cratename: Option<&str>, lints: bool,
dont_insert_main: bool, inject_crate: bool) -> String {
let (crate_attrs, everything_else) = partition_source(s);
let mut prog = String::new(); let mut prog = String::new();
// First push any outer attributes from the example, assuming they
// are intended to be crate attributes.
prog.push_str(&crate_attrs);
if lints { if lints {
prog.push_str(r" prog.push_str(r"
#![allow(unused_variables, unused_assignments, unused_mut, unused_attributes, dead_code)] #![allow(unused_variables, unused_assignments, unused_mut, unused_attributes, dead_code)]
@ -228,7 +268,7 @@ pub fn maketest(s: &str, cratename: Option<&str>, lints: bool, dont_insert_main:
// Don't inject `extern crate std` because it's already injected by the // Don't inject `extern crate std` because it's already injected by the
// compiler. // compiler.
if !s.contains("extern crate") && cratename != Some("std") { if !s.contains("extern crate") && inject_crate {
match cratename { match cratename {
Some(cratename) => { Some(cratename) => {
if s.contains(cratename) { if s.contains(cratename) {
@ -240,16 +280,42 @@ pub fn maketest(s: &str, cratename: Option<&str>, lints: bool, dont_insert_main:
} }
} }
if dont_insert_main || s.contains("fn main") { if dont_insert_main || s.contains("fn main") {
prog.push_str(s); prog.push_str(&everything_else);
} else { } else {
prog.push_str("fn main() {\n "); prog.push_str("fn main() {\n ");
prog.push_str(&s.replace("\n", "\n ")); prog.push_str(&everything_else.replace("\n", "\n "));
prog.push_str("\n}"); prog.push_str("\n}");
} }
info!("final test program: {}", prog);
return prog return prog
} }
fn partition_source(s: &str) -> (String, String) {
use unicode::str::UnicodeStr;
let mut after_header = false;
let mut before = String::new();
let mut after = String::new();
for line in s.lines() {
let trimline = line.trim();
let header = trimline.is_whitespace() ||
trimline.starts_with("#![feature");
if !header || after_header {
after_header = true;
after.push_str(line);
after.push_str("\n");
} else {
before.push_str(line);
before.push_str("\n");
}
}
return (before, after);
}
pub struct Collector { pub struct Collector {
pub tests: Vec<testing::TestDescAndFn>, pub tests: Vec<testing::TestDescAndFn>,
names: Vec<String>, names: Vec<String>,
@ -259,11 +325,12 @@ pub struct Collector {
use_headers: bool, use_headers: bool,
current_header: Option<String>, current_header: Option<String>,
cratename: String, cratename: String,
inject_crate: bool
} }
impl Collector { impl Collector {
pub fn new(cratename: String, libs: SearchPaths, externs: core::Externs, pub fn new(cratename: String, libs: SearchPaths, externs: core::Externs,
use_headers: bool) -> Collector { use_headers: bool, inject_crate: bool) -> Collector {
Collector { Collector {
tests: Vec::new(), tests: Vec::new(),
names: Vec::new(), names: Vec::new(),
@ -273,11 +340,13 @@ impl Collector {
use_headers: use_headers, use_headers: use_headers,
current_header: None, current_header: None,
cratename: cratename, cratename: cratename,
inject_crate: inject_crate
} }
} }
pub fn add_test(&mut self, test: String, pub fn add_test(&mut self, test: String,
should_panic: bool, no_run: bool, should_ignore: bool, as_test_harness: bool) { should_panic: bool, no_run: bool, should_ignore: bool,
as_test_harness: bool) {
let name = if self.use_headers { let name = if self.use_headers {
let s = self.current_header.as_ref().map(|s| &**s).unwrap_or(""); let s = self.current_header.as_ref().map(|s| &**s).unwrap_or("");
format!("{}_{}", s, self.cnt) format!("{}_{}", s, self.cnt)
@ -288,6 +357,7 @@ impl Collector {
let libs = self.libs.clone(); let libs = self.libs.clone();
let externs = self.externs.clone(); let externs = self.externs.clone();
let cratename = self.cratename.to_string(); let cratename = self.cratename.to_string();
let inject_crate = self.inject_crate;
debug!("Creating test {}: {}", name, test); debug!("Creating test {}: {}", name, test);
self.tests.push(testing::TestDescAndFn { self.tests.push(testing::TestDescAndFn {
desc: testing::TestDesc { desc: testing::TestDesc {
@ -302,7 +372,8 @@ impl Collector {
externs, externs,
should_panic, should_panic,
no_run, no_run,
as_test_harness); as_test_harness,
inject_crate);
})) }))
}); });
} }

View File

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

View File

@ -38,7 +38,7 @@ Core encoding and decoding interfaces.
#![feature(unicode)] #![feature(unicode)]
#![feature(str_char)] #![feature(str_char)]
#![feature(convert)] #![feature(convert)]
#![cfg_attr(test, feature(test))] #![cfg_attr(test, feature(test, old_io))]
// test harness access // test harness access
#[cfg(test)] extern crate test; #[cfg(test)] extern crate test;

View File

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

View File

@ -145,6 +145,7 @@ impl<T, S> HashSet<T, S>
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(std_misc)]
/// use std::collections::HashSet; /// use std::collections::HashSet;
/// use std::collections::hash_map::RandomState; /// use std::collections::hash_map::RandomState;
/// ///
@ -169,6 +170,7 @@ impl<T, S> HashSet<T, S>
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(std_misc)]
/// use std::collections::HashSet; /// use std::collections::HashSet;
/// use std::collections::hash_map::RandomState; /// use std::collections::hash_map::RandomState;
/// ///
@ -295,6 +297,7 @@ impl<T, S> HashSet<T, S>
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::collections::HashSet; /// use std::collections::HashSet;
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect(); /// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect(); /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
@ -325,6 +328,7 @@ impl<T, S> HashSet<T, S>
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::collections::HashSet; /// use std::collections::HashSet;
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect(); /// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect(); /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
@ -351,6 +355,7 @@ impl<T, S> HashSet<T, S>
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::collections::HashSet; /// use std::collections::HashSet;
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect(); /// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect(); /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
@ -376,6 +381,7 @@ impl<T, S> HashSet<T, S>
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::collections::HashSet; /// use std::collections::HashSet;
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect(); /// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect(); /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
@ -458,6 +464,7 @@ impl<T, S> HashSet<T, S>
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::collections::HashSet; /// use std::collections::HashSet;
/// ///
/// let set: HashSet<_> = [1, 2, 3].iter().cloned().collect(); /// let set: HashSet<_> = [1, 2, 3].iter().cloned().collect();
@ -477,6 +484,7 @@ impl<T, S> HashSet<T, S>
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::collections::HashSet; /// use std::collections::HashSet;
/// ///
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect(); /// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
@ -498,6 +506,7 @@ impl<T, S> HashSet<T, S>
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::collections::HashSet; /// use std::collections::HashSet;
/// ///
/// let sup: HashSet<_> = [1, 2, 3].iter().cloned().collect(); /// let sup: HashSet<_> = [1, 2, 3].iter().cloned().collect();
@ -519,6 +528,7 @@ impl<T, S> HashSet<T, S>
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # #![feature(core)]
/// use std::collections::HashSet; /// use std::collections::HashSet;
/// ///
/// let sub: HashSet<_> = [1, 2].iter().cloned().collect(); /// 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 //! #### Counting the number of times each character in a string occurs
//! //!
//! ``` //! ```
//! # #![feature(collections)]
//! use std::collections::btree_map::{BTreeMap, Entry}; //! use std::collections::btree_map::{BTreeMap, Entry};
//! //!
//! let mut count = BTreeMap::new(); //! let mut count = BTreeMap::new();
@ -327,6 +328,7 @@
//! #### Tracking the inebriation of customers at a bar //! #### Tracking the inebriation of customers at a bar
//! //!
//! ``` //! ```
//! # #![feature(collections)]
//! use std::collections::btree_map::{BTreeMap, Entry}; //! use std::collections::btree_map::{BTreeMap, Entry};
//! //!
//! // A client of the bar. They have an id and a blood alcohol level. //! // A client of the bar. They have an id and a blood alcohol level.

View File

@ -45,6 +45,7 @@ use vec::Vec;
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![feature(libc)]
/// # extern crate libc; /// # extern crate libc;
/// # fn main() { /// # fn main() {
/// use std::ffi::CString; /// use std::ffi::CString;
@ -83,6 +84,7 @@ pub struct CString {
/// Inspecting a foreign C string /// Inspecting a foreign C string
/// ///
/// ```no_run /// ```no_run
/// # #![feature(libc)]
/// extern crate libc; /// extern crate libc;
/// use std::ffi::CStr; /// use std::ffi::CStr;
/// ///
@ -99,6 +101,7 @@ pub struct CString {
/// Passing a Rust-originating C string /// Passing a Rust-originating C string
/// ///
/// ```no_run /// ```no_run
/// # #![feature(libc)]
/// extern crate libc; /// extern crate libc;
/// use std::ffi::{CString, CStr}; /// use std::ffi::{CString, CStr};
/// ///
@ -147,6 +150,7 @@ impl CString {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![feature(libc)]
/// extern crate libc; /// extern crate libc;
/// use std::ffi::CString; /// use std::ffi::CString;
/// ///
@ -182,6 +186,7 @@ impl CString {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![feature(libc)]
/// extern crate libc; /// extern crate libc;
/// use std::ffi::CString; /// use std::ffi::CString;
/// ///
@ -332,6 +337,7 @@ impl CStr {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![feature(libc)]
/// # extern crate libc; /// # extern crate libc;
/// # fn main() { /// # fn main() {
/// use std::ffi::CStr; /// use std::ffi::CStr;

View File

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

View File

@ -105,6 +105,7 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/", html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")] html_playground_url = "http://play.rust-lang.org/")]
#![doc(test(no_crate_inject))]
#![feature(alloc)] #![feature(alloc)]
#![feature(box_syntax)] #![feature(box_syntax)]
@ -130,7 +131,7 @@
#![feature(allow_internal_unstable)] #![feature(allow_internal_unstable)]
#![feature(str_char)] #![feature(str_char)]
#![feature(into_cow)] #![feature(into_cow)]
#![cfg_attr(test, feature(test, rustc_private))] #![cfg_attr(test, feature(test, rustc_private, std_misc))]
// Don't link to std. We are std. // Don't link to std. We are std.
#![feature(no_std)] #![feature(no_std)]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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