From ddb029034b734ec078589724c45e6eb8bf2e6645 Mon Sep 17 00:00:00 2001 From: Alexis Beingessner Date: Wed, 29 Jul 2015 17:15:11 -0700 Subject: [PATCH] fix example code --- src/doc/tarpl/borrow-splitting.md | 4 +++- src/doc/tarpl/dropck.md | 6 +++--- src/doc/tarpl/leaking.md | 2 +- src/doc/tarpl/safe-unsafe-meaning.md | 2 +- src/doc/tarpl/vec-layout.md | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/doc/tarpl/borrow-splitting.md b/src/doc/tarpl/borrow-splitting.md index fe5f2343dec..123e2baf8fa 100644 --- a/src/doc/tarpl/borrow-splitting.md +++ b/src/doc/tarpl/borrow-splitting.md @@ -137,6 +137,7 @@ impl<'a, T> Iterator for IterMut<'a, T> { Here's a mutable slice: ```rust +# fn main() {} use std::mem; pub struct IterMut<'a, T: 'a>(&'a mut[T]); @@ -170,6 +171,7 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> { And here's a binary tree: ```rust +# fn main() {} use std::collections::VecDeque; type Link = Option>>; @@ -262,7 +264,7 @@ impl<'a, T> Iterator for IterMut<'a, T> { } impl<'a, T> DoubleEndedIterator for IterMut<'a, T> { - fn next(&mut self) -> Option { + fn next_back(&mut self) -> Option { loop { match self.0.back_mut().and_then(|node_it| node_it.next_back()) { Some(State::Elem(elem)) => return Some(elem), diff --git a/src/doc/tarpl/dropck.md b/src/doc/tarpl/dropck.md index 419c61281d9..c75bf8b1179 100644 --- a/src/doc/tarpl/dropck.md +++ b/src/doc/tarpl/dropck.md @@ -8,12 +8,12 @@ when we talked about `'a: 'b`, it was ok for `'a` to live *exactly* as long as gets dropped at the same time as another, right? This is why we used the following desugarring of `let` statements: -```rust +```rust,ignore let x; let y; ``` -```rust +```rust,ignore { let x; { @@ -25,7 +25,7 @@ let y; Each creates its own scope, clearly establishing that one drops before the other. However, what if we do the following? -```rust +```rust,ignore let (x, y) = (vec![], vec![]); ``` diff --git a/src/doc/tarpl/leaking.md b/src/doc/tarpl/leaking.md index dcb03b1c8b6..343de99f08a 100644 --- a/src/doc/tarpl/leaking.md +++ b/src/doc/tarpl/leaking.md @@ -188,7 +188,7 @@ data on their parent's stack without any synchronization over that data by ensuring the parent joins the thread before any of the shared data goes out of scope. -```rust +```rust,ignore pub fn scoped<'a, F>(f: F) -> JoinGuard<'a> where F: FnOnce() + Send + 'a ``` diff --git a/src/doc/tarpl/safe-unsafe-meaning.md b/src/doc/tarpl/safe-unsafe-meaning.md index 1a4e5b8ffad..909308397d7 100644 --- a/src/doc/tarpl/safe-unsafe-meaning.md +++ b/src/doc/tarpl/safe-unsafe-meaning.md @@ -114,7 +114,7 @@ implementation: ```rust # use std::cmp::Ordering; # struct MyType; -# pub unsafe trait UnsafeOrd { fn cmp(&self, other: &Self) -> Ordering; } +# unsafe trait UnsafeOrd { fn cmp(&self, other: &Self) -> Ordering; } unsafe impl UnsafeOrd for MyType { fn cmp(&self, other: &Self) -> Ordering { Ordering::Equal diff --git a/src/doc/tarpl/vec-layout.md b/src/doc/tarpl/vec-layout.md index 325399d622b..3df63d5249c 100644 --- a/src/doc/tarpl/vec-layout.md +++ b/src/doc/tarpl/vec-layout.md @@ -12,7 +12,6 @@ pub struct Vec { cap: usize, len: usize, } - # fn main() {} ``` @@ -69,6 +68,7 @@ impl Deref for Unique { unsafe { mem::transmute(&self.ptr) } } } +# fn main() {} ``` Unfortunately the mechanism for stating that your value is non-zero is -- 2.44.0