Skip to content

Show appropriate feature flags in docs #27326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/doc/trpl/choosing-your-guarantees.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ If a field is wrapped in `Cell`, it's a nice indicator that the chunk of data is
stay the same between the time you first read it and when you intend to use it.

```rust
# use std::cell::Cell;
use std::cell::Cell;

let x = Cell::new(1);
let y = &x;
let z = &x;
Expand Down Expand Up @@ -185,7 +186,8 @@ any other borrows active when a mutable borrow is active. If the programmer atte
borrow, the thread will panic.

```rust
# use std::cell::RefCell;
use std::cell::RefCell;

let x = RefCell::new(vec![1,2,3,4]);
{
println!("{:?}", *x.borrow())
Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/intrinsics.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ perform efficient pointer arithmetic, one would import those functions
via a declaration like

```rust
# #![feature(intrinsics)]
#![feature(intrinsics)]
# fn main() {}

extern "rust-intrinsic" {
Expand Down
18 changes: 12 additions & 6 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ impl<T: ?Sized> Arc<T> {
/// # Examples
///
/// ```
/// # #![feature(arc_weak)]
/// #![feature(arc_weak)]
///
/// use std::sync::Arc;
///
/// let five = Arc::new(5);
Expand Down Expand Up @@ -337,7 +338,8 @@ impl<T: Clone> Arc<T> {
/// # Examples
///
/// ```
/// # #![feature(arc_unique)]
/// #![feature(arc_unique)]
///
/// use std::sync::Arc;
///
/// let mut five = Arc::new(5);
Expand Down Expand Up @@ -408,7 +410,8 @@ impl<T: ?Sized> Arc<T> {
/// # Examples
///
/// ```
/// # #![feature(arc_unique, alloc)]
/// #![feature(arc_unique, alloc)]
///
/// extern crate alloc;
/// # fn main() {
/// use alloc::arc::Arc;
Expand Down Expand Up @@ -555,7 +558,8 @@ impl<T: ?Sized> Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(arc_weak)]
/// #![feature(arc_weak)]
///
/// use std::sync::Arc;
///
/// let five = Arc::new(5);
Expand Down Expand Up @@ -599,7 +603,8 @@ impl<T: ?Sized> Clone for Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(arc_weak)]
/// #![feature(arc_weak)]
///
/// use std::sync::Arc;
///
/// let weak_five = Arc::new(5).downgrade();
Expand All @@ -626,7 +631,8 @@ impl<T: ?Sized> Drop for Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(arc_weak)]
/// #![feature(arc_weak)]
///
/// use std::sync::Arc;
///
/// {
Expand Down
12 changes: 8 additions & 4 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ use core::raw::{TraitObject};
/// The following two examples are equivalent:
///
/// ```
/// # #![feature(box_heap)]
/// #![feature(box_heap)]
///
/// #![feature(box_syntax, placement_in_syntax)]
/// use std::boxed::HEAP;
///
Expand Down Expand Up @@ -237,7 +238,8 @@ impl<T : ?Sized> Box<T> {
///
/// # Examples
/// ```
/// # #![feature(box_raw)]
/// #![feature(box_raw)]
///
/// let seventeen = Box::new(17u32);
/// let raw = Box::into_raw(seventeen);
/// let boxed_again = unsafe { Box::from_raw(raw) };
Expand All @@ -260,7 +262,8 @@ impl<T : ?Sized> Box<T> {
///
/// # Examples
/// ```
/// # #![feature(box_raw)]
/// #![feature(box_raw)]
///
/// use std::boxed;
///
/// let seventeen = Box::new(17u32);
Expand Down Expand Up @@ -303,7 +306,8 @@ impl<T: Clone> Clone for Box<T> {
/// # Examples
///
/// ```
/// # #![feature(box_raw)]
/// #![feature(box_raw)]
///
/// let x = Box::new(5);
/// let mut y = Box::new(10);
///
Expand Down
36 changes: 24 additions & 12 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
//! documentation for more details on interior mutability.
//!
//! ```rust
//! # #![feature(rc_weak)]
//! #![feature(rc_weak)]
//!
//! use std::rc::Rc;
//! use std::rc::Weak;
//! use std::cell::RefCell;
Expand Down Expand Up @@ -227,7 +228,8 @@ impl<T> Rc<T> {
/// # Examples
///
/// ```
/// # #![feature(rc_unique)]
/// #![feature(rc_unique)]
///
/// use std::rc::Rc;
///
/// let x = Rc::new(3);
Expand Down Expand Up @@ -262,7 +264,8 @@ impl<T: ?Sized> Rc<T> {
/// # Examples
///
/// ```
/// # #![feature(rc_weak)]
/// #![feature(rc_weak)]
///
/// use std::rc::Rc;
///
/// let five = Rc::new(5);
Expand Down Expand Up @@ -292,7 +295,8 @@ impl<T: ?Sized> Rc<T> {
/// # Examples
///
/// ```
/// # #![feature(rc_unique)]
/// #![feature(rc_unique)]
///
/// use std::rc::Rc;
///
/// let five = Rc::new(5);
Expand All @@ -313,7 +317,8 @@ impl<T: ?Sized> Rc<T> {
/// # Examples
///
/// ```
/// # #![feature(rc_unique)]
/// #![feature(rc_unique)]
///
/// use std::rc::Rc;
///
/// let mut x = Rc::new(3);
Expand Down Expand Up @@ -353,7 +358,8 @@ pub fn strong_count<T: ?Sized>(this: &Rc<T>) -> usize { Rc::strong_count(this) }
/// # Examples
///
/// ```
/// # #![feature(rc_unique)]
/// #![feature(rc_unique)]
///
/// use std::rc;
/// use std::rc::Rc;
///
Expand All @@ -373,7 +379,8 @@ pub fn is_unique<T>(rc: &Rc<T>) -> bool { Rc::is_unique(rc) }
/// # Examples
///
/// ```
/// # #![feature(rc_unique)]
/// #![feature(rc_unique)]
///
/// use std::rc::{self, Rc};
///
/// let x = Rc::new(3);
Expand All @@ -395,7 +402,8 @@ pub fn try_unwrap<T>(rc: Rc<T>) -> Result<T, Rc<T>> { Rc::try_unwrap(rc) }
/// # Examples
///
/// ```
/// # #![feature(rc_unique)]
/// #![feature(rc_unique)]
///
/// use std::rc::{self, Rc};
///
/// let mut x = Rc::new(3);
Expand All @@ -419,7 +427,8 @@ impl<T: Clone> Rc<T> {
/// # Examples
///
/// ```
/// # #![feature(rc_unique)]
/// #![feature(rc_unique)]
///
/// use std::rc::Rc;
///
/// let mut five = Rc::new(5);
Expand Down Expand Up @@ -750,7 +759,8 @@ impl<T: ?Sized> Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(rc_weak)]
/// #![feature(rc_weak)]
///
/// use std::rc::Rc;
///
/// let five = Rc::new(5);
Expand Down Expand Up @@ -778,7 +788,8 @@ impl<T: ?Sized> Drop for Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(rc_weak)]
/// #![feature(rc_weak)]
///
/// use std::rc::Rc;
///
/// {
Expand Down Expand Up @@ -825,7 +836,8 @@ impl<T: ?Sized> Clone for Weak<T> {
/// # Examples
///
/// ```
/// # #![feature(rc_weak)]
/// #![feature(rc_weak)]
///
/// use std::rc::Rc;
///
/// let weak_five = Rc::new(5).downgrade();
Expand Down
24 changes: 16 additions & 8 deletions src/libcollections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// #![feature(collections)]
///
/// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from_vec(vec![9, 1, 2, 7, 3, 2]);
/// ```
Expand All @@ -236,7 +237,8 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// #![feature(collections)]
///
/// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]);
///
Expand Down Expand Up @@ -341,7 +343,8 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// #![feature(collections)]
///
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::from_vec(vec![1, 3]);
///
Expand Down Expand Up @@ -387,7 +390,8 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// #![feature(collections)]
///
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::new();
/// heap.push(1);
Expand Down Expand Up @@ -419,7 +423,8 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// #![feature(collections)]
///
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::new();
///
Expand All @@ -445,7 +450,8 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// #![feature(collections)]
///
/// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4, 5, 6, 7]);
/// let vec = heap.into_vec();
Expand All @@ -463,7 +469,8 @@ impl<T: Ord> BinaryHeap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// #![feature(collections)]
///
/// use std::collections::BinaryHeap;
///
/// let mut heap = BinaryHeap::from_vec(vec![1, 2, 4, 5, 7]);
Expand Down Expand Up @@ -724,7 +731,8 @@ impl<T: Ord> IntoIterator for BinaryHeap<T> {
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// #![feature(collections)]
///
/// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]);
///
Expand Down
Loading