Skip to content

Commit ba5fcb7

Browse files
committed
Show appropriate feature flags in docs
1 parent d019a49 commit ba5fcb7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+419
-214
lines changed

src/doc/trpl/choosing-your-guarantees.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ If a field is wrapped in `Cell`, it's a nice indicator that the chunk of data is
127127
stay the same between the time you first read it and when you intend to use it.
128128

129129
```rust
130-
# use std::cell::Cell;
130+
use std::cell::Cell;
131+
131132
let x = Cell::new(1);
132133
let y = &x;
133134
let z = &x;
@@ -185,7 +186,8 @@ any other borrows active when a mutable borrow is active. If the programmer atte
185186
borrow, the thread will panic.
186187

187188
```rust
188-
# use std::cell::RefCell;
189+
use std::cell::RefCell;
190+
189191
let x = RefCell::new(vec![1,2,3,4]);
190192
{
191193
println!("{:?}", *x.borrow())

src/doc/trpl/intrinsics.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ perform efficient pointer arithmetic, one would import those functions
1111
via a declaration like
1212

1313
```rust
14-
# #![feature(intrinsics)]
14+
#![feature(intrinsics)]
1515
# fn main() {}
1616

1717
extern "rust-intrinsic" {

src/liballoc/arc.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ impl<T: ?Sized> Arc<T> {
200200
/// # Examples
201201
///
202202
/// ```
203-
/// # #![feature(arc_weak)]
203+
/// #![feature(arc_weak)]
204+
///
204205
/// use std::sync::Arc;
205206
///
206207
/// let five = Arc::new(5);
@@ -337,7 +338,8 @@ impl<T: Clone> Arc<T> {
337338
/// # Examples
338339
///
339340
/// ```
340-
/// # #![feature(arc_unique)]
341+
/// #![feature(arc_unique)]
342+
///
341343
/// use std::sync::Arc;
342344
///
343345
/// let mut five = Arc::new(5);
@@ -408,7 +410,8 @@ impl<T: ?Sized> Arc<T> {
408410
/// # Examples
409411
///
410412
/// ```
411-
/// # #![feature(arc_unique, alloc)]
413+
/// #![feature(arc_unique, alloc)]
414+
///
412415
/// extern crate alloc;
413416
/// # fn main() {
414417
/// use alloc::arc::Arc;
@@ -555,7 +558,8 @@ impl<T: ?Sized> Weak<T> {
555558
/// # Examples
556559
///
557560
/// ```
558-
/// # #![feature(arc_weak)]
561+
/// #![feature(arc_weak)]
562+
///
559563
/// use std::sync::Arc;
560564
///
561565
/// let five = Arc::new(5);
@@ -599,7 +603,8 @@ impl<T: ?Sized> Clone for Weak<T> {
599603
/// # Examples
600604
///
601605
/// ```
602-
/// # #![feature(arc_weak)]
606+
/// #![feature(arc_weak)]
607+
///
603608
/// use std::sync::Arc;
604609
///
605610
/// let weak_five = Arc::new(5).downgrade();
@@ -626,7 +631,8 @@ impl<T: ?Sized> Drop for Weak<T> {
626631
/// # Examples
627632
///
628633
/// ```
629-
/// # #![feature(arc_weak)]
634+
/// #![feature(arc_weak)]
635+
///
630636
/// use std::sync::Arc;
631637
///
632638
/// {

src/liballoc/boxed.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ use core::raw::{TraitObject};
7474
/// The following two examples are equivalent:
7575
///
7676
/// ```
77-
/// # #![feature(box_heap)]
77+
/// #![feature(box_heap)]
78+
///
7879
/// #![feature(box_syntax, placement_in_syntax)]
7980
/// use std::boxed::HEAP;
8081
///
@@ -237,7 +238,8 @@ impl<T : ?Sized> Box<T> {
237238
///
238239
/// # Examples
239240
/// ```
240-
/// # #![feature(box_raw)]
241+
/// #![feature(box_raw)]
242+
///
241243
/// let seventeen = Box::new(17u32);
242244
/// let raw = Box::into_raw(seventeen);
243245
/// let boxed_again = unsafe { Box::from_raw(raw) };
@@ -260,7 +262,8 @@ impl<T : ?Sized> Box<T> {
260262
///
261263
/// # Examples
262264
/// ```
263-
/// # #![feature(box_raw)]
265+
/// #![feature(box_raw)]
266+
///
264267
/// use std::boxed;
265268
///
266269
/// let seventeen = Box::new(17u32);
@@ -303,7 +306,8 @@ impl<T: Clone> Clone for Box<T> {
303306
/// # Examples
304307
///
305308
/// ```
306-
/// # #![feature(box_raw)]
309+
/// #![feature(box_raw)]
310+
///
307311
/// let x = Box::new(5);
308312
/// let mut y = Box::new(10);
309313
///

src/liballoc/rc.rs

+24-12
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@
9191
//! documentation for more details on interior mutability.
9292
//!
9393
//! ```rust
94-
//! # #![feature(rc_weak)]
94+
//! #![feature(rc_weak)]
95+
//!
9596
//! use std::rc::Rc;
9697
//! use std::rc::Weak;
9798
//! use std::cell::RefCell;
@@ -227,7 +228,8 @@ impl<T> Rc<T> {
227228
/// # Examples
228229
///
229230
/// ```
230-
/// # #![feature(rc_unique)]
231+
/// #![feature(rc_unique)]
232+
///
231233
/// use std::rc::Rc;
232234
///
233235
/// let x = Rc::new(3);
@@ -262,7 +264,8 @@ impl<T: ?Sized> Rc<T> {
262264
/// # Examples
263265
///
264266
/// ```
265-
/// # #![feature(rc_weak)]
267+
/// #![feature(rc_weak)]
268+
///
266269
/// use std::rc::Rc;
267270
///
268271
/// let five = Rc::new(5);
@@ -292,7 +295,8 @@ impl<T: ?Sized> Rc<T> {
292295
/// # Examples
293296
///
294297
/// ```
295-
/// # #![feature(rc_unique)]
298+
/// #![feature(rc_unique)]
299+
///
296300
/// use std::rc::Rc;
297301
///
298302
/// let five = Rc::new(5);
@@ -313,7 +317,8 @@ impl<T: ?Sized> Rc<T> {
313317
/// # Examples
314318
///
315319
/// ```
316-
/// # #![feature(rc_unique)]
320+
/// #![feature(rc_unique)]
321+
///
317322
/// use std::rc::Rc;
318323
///
319324
/// let mut x = Rc::new(3);
@@ -353,7 +358,8 @@ pub fn strong_count<T: ?Sized>(this: &Rc<T>) -> usize { Rc::strong_count(this) }
353358
/// # Examples
354359
///
355360
/// ```
356-
/// # #![feature(rc_unique)]
361+
/// #![feature(rc_unique)]
362+
///
357363
/// use std::rc;
358364
/// use std::rc::Rc;
359365
///
@@ -373,7 +379,8 @@ pub fn is_unique<T>(rc: &Rc<T>) -> bool { Rc::is_unique(rc) }
373379
/// # Examples
374380
///
375381
/// ```
376-
/// # #![feature(rc_unique)]
382+
/// #![feature(rc_unique)]
383+
///
377384
/// use std::rc::{self, Rc};
378385
///
379386
/// let x = Rc::new(3);
@@ -395,7 +402,8 @@ pub fn try_unwrap<T>(rc: Rc<T>) -> Result<T, Rc<T>> { Rc::try_unwrap(rc) }
395402
/// # Examples
396403
///
397404
/// ```
398-
/// # #![feature(rc_unique)]
405+
/// #![feature(rc_unique)]
406+
///
399407
/// use std::rc::{self, Rc};
400408
///
401409
/// let mut x = Rc::new(3);
@@ -419,7 +427,8 @@ impl<T: Clone> Rc<T> {
419427
/// # Examples
420428
///
421429
/// ```
422-
/// # #![feature(rc_unique)]
430+
/// #![feature(rc_unique)]
431+
///
423432
/// use std::rc::Rc;
424433
///
425434
/// let mut five = Rc::new(5);
@@ -750,7 +759,8 @@ impl<T: ?Sized> Weak<T> {
750759
/// # Examples
751760
///
752761
/// ```
753-
/// # #![feature(rc_weak)]
762+
/// #![feature(rc_weak)]
763+
///
754764
/// use std::rc::Rc;
755765
///
756766
/// let five = Rc::new(5);
@@ -778,7 +788,8 @@ impl<T: ?Sized> Drop for Weak<T> {
778788
/// # Examples
779789
///
780790
/// ```
781-
/// # #![feature(rc_weak)]
791+
/// #![feature(rc_weak)]
792+
///
782793
/// use std::rc::Rc;
783794
///
784795
/// {
@@ -825,7 +836,8 @@ impl<T: ?Sized> Clone for Weak<T> {
825836
/// # Examples
826837
///
827838
/// ```
828-
/// # #![feature(rc_weak)]
839+
/// #![feature(rc_weak)]
840+
///
829841
/// use std::rc::Rc;
830842
///
831843
/// let weak_five = Rc::new(5).downgrade();

src/libcollections/binary_heap.rs

+16-8
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ impl<T: Ord> BinaryHeap<T> {
216216
/// # Examples
217217
///
218218
/// ```
219-
/// # #![feature(collections)]
219+
/// #![feature(collections)]
220+
///
220221
/// use std::collections::BinaryHeap;
221222
/// let heap = BinaryHeap::from_vec(vec![9, 1, 2, 7, 3, 2]);
222223
/// ```
@@ -236,7 +237,8 @@ impl<T: Ord> BinaryHeap<T> {
236237
/// # Examples
237238
///
238239
/// ```
239-
/// # #![feature(collections)]
240+
/// #![feature(collections)]
241+
///
240242
/// use std::collections::BinaryHeap;
241243
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]);
242244
///
@@ -341,7 +343,8 @@ impl<T: Ord> BinaryHeap<T> {
341343
/// # Examples
342344
///
343345
/// ```
344-
/// # #![feature(collections)]
346+
/// #![feature(collections)]
347+
///
345348
/// use std::collections::BinaryHeap;
346349
/// let mut heap = BinaryHeap::from_vec(vec![1, 3]);
347350
///
@@ -387,7 +390,8 @@ impl<T: Ord> BinaryHeap<T> {
387390
/// # Examples
388391
///
389392
/// ```
390-
/// # #![feature(collections)]
393+
/// #![feature(collections)]
394+
///
391395
/// use std::collections::BinaryHeap;
392396
/// let mut heap = BinaryHeap::new();
393397
/// heap.push(1);
@@ -419,7 +423,8 @@ impl<T: Ord> BinaryHeap<T> {
419423
/// # Examples
420424
///
421425
/// ```
422-
/// # #![feature(collections)]
426+
/// #![feature(collections)]
427+
///
423428
/// use std::collections::BinaryHeap;
424429
/// let mut heap = BinaryHeap::new();
425430
///
@@ -445,7 +450,8 @@ impl<T: Ord> BinaryHeap<T> {
445450
/// # Examples
446451
///
447452
/// ```
448-
/// # #![feature(collections)]
453+
/// #![feature(collections)]
454+
///
449455
/// use std::collections::BinaryHeap;
450456
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4, 5, 6, 7]);
451457
/// let vec = heap.into_vec();
@@ -463,7 +469,8 @@ impl<T: Ord> BinaryHeap<T> {
463469
/// # Examples
464470
///
465471
/// ```
466-
/// # #![feature(collections)]
472+
/// #![feature(collections)]
473+
///
467474
/// use std::collections::BinaryHeap;
468475
///
469476
/// let mut heap = BinaryHeap::from_vec(vec![1, 2, 4, 5, 7]);
@@ -724,7 +731,8 @@ impl<T: Ord> IntoIterator for BinaryHeap<T> {
724731
/// # Examples
725732
///
726733
/// ```
727-
/// # #![feature(collections)]
734+
/// #![feature(collections)]
735+
///
728736
/// use std::collections::BinaryHeap;
729737
/// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]);
730738
///

0 commit comments

Comments
 (0)