Skip to content

Commit 1c89b0d

Browse files
committed
Merge pull request #21105 from csouth3/kill-box-import
Remove unneeded box import in examples Reviewed-by: alexcrichton
2 parents 69188b4 + 07f723f commit 1c89b0d

File tree

6 files changed

+0
-21
lines changed

6 files changed

+0
-21
lines changed

src/doc/reference.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,6 @@ pointer values (pointing to a type for which an implementation of the given
15881588
trait is in scope) to pointers to the trait name, used as a type.
15891589

15901590
```
1591-
# use std::boxed::Box;
15921591
# trait Shape { }
15931592
# impl Shape for int { }
15941593
# let mycircle = 0i;
@@ -1647,7 +1646,6 @@ fn radius_times_area<T: Circle>(c: T) -> f64 {
16471646
Likewise, supertrait methods may also be called on trait objects.
16481647

16491648
```{.ignore}
1650-
# use std::boxed::Box;
16511649
# trait Shape { fn area(&self) -> f64; }
16521650
# trait Circle : Shape { fn radius(&self) -> f64; }
16531651
# impl Shape for int { fn area(&self) -> f64 { 0.0 } }
@@ -3792,7 +3790,6 @@ enclosing `enum` or `struct` type itself. Such recursion has restrictions:
37923790
An example of a *recursive* type and its use:
37933791

37943792
```
3795-
# use std::boxed::Box;
37963793
enum List<T> {
37973794
Nil,
37983795
Cons(T, Box<List<T>>)
@@ -3905,7 +3902,6 @@ implementation of `R`, and the pointer value of `E`.
39053902
An example of an object type:
39063903

39073904
```
3908-
# use std::boxed::Box;
39093905
trait Printable {
39103906
fn stringify(&self) -> String;
39113907
}
@@ -4113,7 +4109,6 @@ the type of a box is `std::owned::Box<T>`.
41134109
An example of a box type and value:
41144110

41154111
```
4116-
# use std::boxed::Box;
41174112
let x: Box<int> = Box::new(10);
41184113
```
41194114

@@ -4123,7 +4118,6 @@ copy of a box to move ownership of the value. After a value has been moved,
41234118
the source location cannot be used unless it is reinitialized.
41244119

41254120
```
4126-
# use std::boxed::Box;
41274121
let x: Box<int> = Box::new(10);
41284122
let y = x;
41294123
// attempting to use `x` will result in an error here

src/doc/trpl/ffi.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,6 @@ referenced Rust object.
262262
Rust code:
263263
264264
~~~~no_run
265-
# use std::boxed::Box;
266-
267265
#[repr(C)]
268266
struct RustObject {
269267
a: i32,

src/doc/trpl/pointers.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ fn rc_succ(x: Rc<int>) -> int { *x + 1 }
455455
Note that the caller of your function will have to modify their calls slightly:
456456

457457
```{rust}
458-
# use std::boxed::Box;
459458
use std::rc::Rc;
460459
461460
fn succ(x: &int) -> int { *x + 1 }
@@ -478,15 +477,13 @@ those contents.
478477
heap allocation in Rust. Creating a box looks like this:
479478

480479
```{rust}
481-
# use std::boxed::Box;
482480
let x = Box::new(5i);
483481
```
484482

485483
Boxes are heap allocated and they are deallocated automatically by Rust when
486484
they go out of scope:
487485

488486
```{rust}
489-
# use std::boxed::Box;
490487
{
491488
let x = Box::new(5i);
492489
@@ -507,7 +504,6 @@ You don't need to fully grok the theory of affine types or regions to grok
507504
boxes, though. As a rough approximation, you can treat this Rust code:
508505

509506
```{rust}
510-
# use std::boxed::Box;
511507
{
512508
let x = Box::new(5i);
513509
@@ -548,7 +544,6 @@ for more detail on how lifetimes work.
548544
Using boxes and references together is very common. For example:
549545

550546
```{rust}
551-
# use std::boxed::Box;
552547
fn add_one(x: &int) -> int {
553548
*x + 1
554549
}
@@ -566,7 +561,6 @@ function, and since it's only reading the value, allows it.
566561
We can borrow `x` multiple times, as long as it's not simultaneous:
567562

568563
```{rust}
569-
# use std::boxed::Box;
570564
fn add_one(x: &int) -> int {
571565
*x + 1
572566
}
@@ -583,7 +577,6 @@ fn main() {
583577
Or as long as it's not a mutable borrow. This will error:
584578

585579
```{rust,ignore}
586-
# use std::boxed::Box;
587580
fn add_one(x: &mut int) -> int {
588581
*x + 1
589582
}
@@ -610,7 +603,6 @@ Sometimes, you need a recursive data structure. The simplest is known as a
610603

611604

612605
```{rust}
613-
# use std::boxed::Box;
614606
#[derive(Show)]
615607
enum List<T> {
616608
Cons(T, Box<List<T>>),
@@ -666,7 +658,6 @@ In many languages with pointers, you'd return a pointer from a function
666658
so as to avoid copying a large data structure. For example:
667659

668660
```{rust}
669-
# use std::boxed::Box;
670661
struct BigStruct {
671662
one: int,
672663
two: int,
@@ -695,7 +686,6 @@ than the hundred `int`s that make up the `BigStruct`.
695686
This is an antipattern in Rust. Instead, write this:
696687

697688
```{rust}
698-
# use std::boxed::Box;
699689
struct BigStruct {
700690
one: int,
701691
two: int,

src/doc/trpl/unsafe.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ extern crate libc;
197197
use libc::{c_void, size_t, malloc, free};
198198
use std::mem;
199199
use std::ptr;
200-
# use std::boxed::Box;
201200
202201
// Define a wrapper around the handle returned by the foreign code.
203202
// Unique<T> has the same semantics as Box<T>

src/libcore/option.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
//! not (`None`).
6767
//!
6868
//! ```
69-
//! # use std::boxed::Box;
7069
//! let optional: Option<Box<int>> = None;
7170
//! check_optional(&optional);
7271
//!

src/libcore/ptr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
//! though unsafely, transformed from one type to the other.
4747
//!
4848
//! ```
49-
//! # use std::boxed::Box;
5049
//! use std::mem;
5150
//!
5251
//! unsafe {

0 commit comments

Comments
 (0)