diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2015-07-29 10:30:34 -0400 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2015-07-29 10:30:34 -0400 |
| commit | a368adf8e5bd1166b9fd915ed1db674872f5a1bc (patch) | |
| tree | 0bff3f548092867b8673da6d82aeaee05ce666fb /src/libcore | |
| parent | 6fec7b7854b0598c82af68587ba163e406c3e17c (diff) | |
| parent | ba5fcb726fb88cc8393f48c9f46ba03fcadf0511 (diff) | |
| download | rust-a368adf8e5bd1166b9fd915ed1db674872f5a1bc.tar.gz rust-a368adf8e5bd1166b9fd915ed1db674872f5a1bc.zip | |
Rollup merge of #27326 - steveklabnik:doc_show_use, r=Gankro
In spirit with https://internals.rust-lang.org/t/should-we-keep-including-obvious-imports-in-code-examples/2217, show the feature flags we're using in examples. (also one instance of 'use')
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/cell.rs | 6 | ||||
| -rw-r--r-- | src/libcore/cmp.rs | 12 | ||||
| -rw-r--r-- | src/libcore/fmt/num.rs | 3 | ||||
| -rw-r--r-- | src/libcore/hash/mod.rs | 6 | ||||
| -rw-r--r-- | src/libcore/iter.rs | 21 | ||||
| -rw-r--r-- | src/libcore/option.rs | 3 | ||||
| -rw-r--r-- | src/libcore/raw.rs | 6 | ||||
| -rw-r--r-- | src/libcore/result.rs | 3 | ||||
| -rw-r--r-- | src/libcore/simd.rs | 3 |
9 files changed, 42 insertions, 21 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 2c4ebeafc0b..c443270d5f4 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -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')); diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 93542185eab..9d151abea78 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -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); @@ -417,7 +419,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)); @@ -427,7 +430,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); diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 8141916dd60..7cacc6af575 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -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()); /// ``` diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index a660cf0cf2d..75b7208d66b 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -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 { diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 4d8de0c85b6..2968d634544 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -824,7 +824,8 @@ pub trait Iterator { /// # Examples /// /// ``` - /// # #![feature(iter_min_max)] + /// #![feature(iter_min_max)] + /// /// use std::iter::MinMaxResult::{NoElements, OneElement, MinMax}; /// /// let a: [i32; 0] = []; @@ -898,7 +899,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); /// ``` @@ -926,7 +928,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); /// ``` @@ -1065,7 +1068,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); @@ -1083,7 +1087,8 @@ pub trait Iterator { /// # Examples /// /// ``` - /// # #![feature(iter_arith)] + /// #![feature(iter_arith)] + /// /// fn factorial(n: u32) -> u32 { /// (1..).take_while(|&i| i <= n).product() /// } @@ -1367,7 +1372,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; @@ -2764,7 +2770,8 @@ impl<A: Step> ops::Range<A> { /// # Examples /// /// ``` - /// # #![feature(step_by)] + /// #![feature(step_by)] + /// /// for i in (0..10).step_by(2) { /// println!("{}", i); /// } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 9ccba7ad78d..2235dc4af11 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -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(); diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index 43535ddd1d5..f0bac1bfef3 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -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; /// diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 2b33b1f83d2..100cf0779b7 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -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(); diff --git a/src/libcore/simd.rs b/src/libcore/simd.rs index 7ecd08bea35..d0205fc9b12 100644 --- a/src/libcore/simd.rs +++ b/src/libcore/simd.rs @@ -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); |
