Show appropriate feature flags in docs

This commit is contained in:
Steve Klabnik
2015-07-27 10:50:19 -04:00
parent d019a49ac8
commit ba5fcb726f
47 changed files with 419 additions and 214 deletions

View File

@@ -221,7 +221,8 @@ impl<T:Copy> Cell<T> {
/// # Examples
///
/// ```
/// # #![feature(as_unsafe_cell)]
/// #![feature(as_unsafe_cell)]
///
/// use std::cell::Cell;
///
/// let c = Cell::new(5);
@@ -589,7 +590,8 @@ impl<'b, T: ?Sized> Ref<'b, T> {
/// # Example
///
/// ```
/// # #![feature(cell_extras)]
/// #![feature(cell_extras)]
///
/// use std::cell::{RefCell, Ref};
///
/// let c = RefCell::new((5, 'b'));

View File

@@ -383,7 +383,8 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
/// # Examples
///
/// ```
/// # #![feature(cmp_partial)]
/// #![feature(cmp_partial)]
///
/// use std::cmp;
///
/// assert_eq!(Some(1), cmp::partial_min(1, 2));
@@ -393,7 +394,8 @@ pub fn max<T: Ord>(v1: T, v2: T) -> T {
/// When comparison is impossible:
///
/// ```
/// # #![feature(cmp_partial)]
/// #![feature(cmp_partial)]
///
/// use std::cmp;
///
/// let result = cmp::partial_min(std::f64::NAN, 1.0);
@@ -416,7 +418,8 @@ pub fn partial_min<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
/// # Examples
///
/// ```
/// # #![feature(cmp_partial)]
/// #![feature(cmp_partial)]
///
/// use std::cmp;
///
/// assert_eq!(Some(2), cmp::partial_max(1, 2));
@@ -426,7 +429,8 @@ pub fn partial_min<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
/// When comparison is impossible:
///
/// ```
/// # #![feature(cmp_partial)]
/// #![feature(cmp_partial)]
///
/// use std::cmp;
///
/// let result = cmp::partial_max(std::f64::NAN, 1.0);

View File

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

View File

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

View File

@@ -822,7 +822,8 @@ pub trait Iterator {
/// # Examples
///
/// ```
/// # #![feature(iter_min_max)]
/// #![feature(iter_min_max)]
///
/// use std::iter::MinMaxResult::{NoElements, OneElement, MinMax};
///
/// let a: [i32; 0] = [];
@@ -894,7 +895,8 @@ pub trait Iterator {
/// # Examples
///
/// ```
/// # #![feature(iter_cmp)]
/// #![feature(iter_cmp)]
///
/// let a = [-3_i32, 0, 1, 5, -10];
/// assert_eq!(*a.iter().max_by(|x| x.abs()).unwrap(), -10);
/// ```
@@ -922,7 +924,8 @@ pub trait Iterator {
/// # Examples
///
/// ```
/// # #![feature(iter_cmp)]
/// #![feature(iter_cmp)]
///
/// let a = [-3_i32, 0, 1, 5, -10];
/// assert_eq!(*a.iter().min_by(|x| x.abs()).unwrap(), 0);
/// ```
@@ -1061,7 +1064,8 @@ pub trait Iterator {
/// # Examples
///
/// ```
/// # #![feature(iter_arith)]
/// #![feature(iter_arith)]
///
/// let a = [1, 2, 3, 4, 5];
/// let it = a.iter();
/// assert_eq!(it.sum::<i32>(), 15);
@@ -1079,7 +1083,8 @@ pub trait Iterator {
/// # Examples
///
/// ```
/// # #![feature(iter_arith)]
/// #![feature(iter_arith)]
///
/// fn factorial(n: u32) -> u32 {
/// (1..).take_while(|&i| i <= n).product()
/// }
@@ -1359,7 +1364,8 @@ impl<T: Clone> MinMaxResult<T> {
/// # Examples
///
/// ```
/// # #![feature(iter_min_max)]
/// #![feature(iter_min_max)]
///
/// use std::iter::MinMaxResult::{self, NoElements, OneElement, MinMax};
///
/// let r: MinMaxResult<i32> = NoElements;
@@ -2751,7 +2757,8 @@ impl<A: Step> ops::Range<A> {
/// # Examples
///
/// ```
/// # #![feature(step_by)]
/// #![feature(step_by)]
///
/// for i in (0..10).step_by(2) {
/// println!("{}", i);
/// }

View File

@@ -274,7 +274,8 @@ impl<T> Option<T> {
/// # Examples
///
/// ```
/// # #![feature(as_slice)]
/// #![feature(as_slice)]
///
/// let mut x = Some("Diamonds");
/// {
/// let v = x.as_mut_slice();

View File

@@ -49,7 +49,8 @@ use mem;
/// # Examples
///
/// ```
/// # #![feature(raw)]
/// #![feature(raw)]
///
/// use std::raw::{self, Repr};
///
/// let slice: &[u16] = &[1, 2, 3, 4];
@@ -98,7 +99,8 @@ impl<T> Clone for Slice<T> {
/// # Examples
///
/// ```
/// # #![feature(raw)]
/// #![feature(raw)]
///
/// use std::mem;
/// use std::raw;
///

View File

@@ -420,7 +420,8 @@ impl<T, E> Result<T, E> {
/// Converts from `Result<T, E>` to `&mut [T]` (without copying)
///
/// ```
/// # #![feature(as_slice)]
/// #![feature(as_slice)]
///
/// let mut x: Result<&str, u32> = Ok("Gold");
/// {
/// let v = x.as_mut_slice();

View File

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