Skip to content

Commit ddb0290

Browse files
committed
fix example code
1 parent 4c48ffa commit ddb0290

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

src/doc/tarpl/borrow-splitting.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ impl<'a, T> Iterator for IterMut<'a, T> {
137137
Here's a mutable slice:
138138

139139
```rust
140+
# fn main() {}
140141
use std::mem;
141142

142143
pub struct IterMut<'a, T: 'a>(&'a mut[T]);
@@ -170,6 +171,7 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
170171
And here's a binary tree:
171172

172173
```rust
174+
# fn main() {}
173175
use std::collections::VecDeque;
174176

175177
type Link<T> = Option<Box<Node<T>>>;
@@ -262,7 +264,7 @@ impl<'a, T> Iterator for IterMut<'a, T> {
262264
}
263265

264266
impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
265-
fn next(&mut self) -> Option<Self::Item> {
267+
fn next_back(&mut self) -> Option<Self::Item> {
266268
loop {
267269
match self.0.back_mut().and_then(|node_it| node_it.next_back()) {
268270
Some(State::Elem(elem)) => return Some(elem),

src/doc/tarpl/dropck.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ when we talked about `'a: 'b`, it was ok for `'a` to live *exactly* as long as
88
gets dropped at the same time as another, right? This is why we used the
99
following desugarring of `let` statements:
1010

11-
```rust
11+
```rust,ignore
1212
let x;
1313
let y;
1414
```
1515

16-
```rust
16+
```rust,ignore
1717
{
1818
let x;
1919
{
@@ -25,7 +25,7 @@ let y;
2525
Each creates its own scope, clearly establishing that one drops before the
2626
other. However, what if we do the following?
2727

28-
```rust
28+
```rust,ignore
2929
let (x, y) = (vec![], vec![]);
3030
```
3131

src/doc/tarpl/leaking.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ data on their parent's stack without any synchronization over that data by
188188
ensuring the parent joins the thread before any of the shared data goes out
189189
of scope.
190190

191-
```rust
191+
```rust,ignore
192192
pub fn scoped<'a, F>(f: F) -> JoinGuard<'a>
193193
where F: FnOnce() + Send + 'a
194194
```

src/doc/tarpl/safe-unsafe-meaning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ implementation:
114114
```rust
115115
# use std::cmp::Ordering;
116116
# struct MyType;
117-
# pub unsafe trait UnsafeOrd { fn cmp(&self, other: &Self) -> Ordering; }
117+
# unsafe trait UnsafeOrd { fn cmp(&self, other: &Self) -> Ordering; }
118118
unsafe impl UnsafeOrd for MyType {
119119
fn cmp(&self, other: &Self) -> Ordering {
120120
Ordering::Equal

src/doc/tarpl/vec-layout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub struct Vec<T> {
1212
cap: usize,
1313
len: usize,
1414
}
15-
1615
# fn main() {}
1716
```
1817

@@ -69,6 +68,7 @@ impl<T> Deref for Unique<T> {
6968
unsafe { mem::transmute(&self.ptr) }
7069
}
7170
}
71+
# fn main() {}
7272
```
7373

7474
Unfortunately the mechanism for stating that your value is non-zero is

0 commit comments

Comments
 (0)