Skip to content

Commit 07f723f

Browse files
committed
Remove unneeded box import in examples
1 parent e94a9f0 commit 07f723f

File tree

7 files changed

+0
-25
lines changed

7 files changed

+0
-25
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 } }
@@ -3799,7 +3797,6 @@ enclosing `enum` or `struct` type itself. Such recursion has restrictions:
37993797
An example of a *recursive* type and its use:
38003798

38013799
```
3802-
# use std::boxed::Box;
38033800
enum List<T> {
38043801
Nil,
38053802
Cons(T, Box<List<T>>)
@@ -3912,7 +3909,6 @@ implementation of `R`, and the pointer value of `E`.
39123909
An example of an object type:
39133910

39143911
```
3915-
# use std::boxed::Box;
39163912
trait Printable {
39173913
fn stringify(&self) -> String;
39183914
}
@@ -4120,7 +4116,6 @@ the type of a box is `std::owned::Box<T>`.
41204116
An example of a box type and value:
41214117

41224118
```
4123-
# use std::boxed::Box;
41244119
let x: Box<int> = Box::new(10);
41254120
```
41264121

@@ -4130,7 +4125,6 @@ copy of a box to move ownership of the value. After a value has been moved,
41304125
the source location cannot be used unless it is reinitialized.
41314126

41324127
```
4133-
# use std::boxed::Box;
41344128
let x: Box<int> = Box::new(10);
41354129
let y = x;
41364130
// 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/ownership.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ therefore deallocates the memory for you. Here's the equivalent example in
8181
Rust:
8282

8383
```rust
84-
# use std::boxed::Box;
8584
{
8685
let x = Box::new(5);
8786
}
@@ -101,7 +100,6 @@ This is pretty straightforward, but what happens when we want to pass our box
101100
to a function? Let's look at some code:
102101

103102
```rust
104-
# use std::boxed::Box;
105103
fn main() {
106104
let x = Box::new(5);
107105

@@ -117,7 +115,6 @@ This code works, but it's not ideal. For example, let's add one more line of
117115
code, where we print out the value of `x`:
118116

119117
```{rust,ignore}
120-
# use std::boxed::Box;
121118
fn main() {
122119
let x = Box::new(5);
123120
@@ -151,7 +148,6 @@ To fix this, we can have `add_one` give ownership back when it's done with the
151148
box:
152149

153150
```rust
154-
# use std::boxed::Box;
155151
fn main() {
156152
let x = Box::new(5);
157153

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)