]> git.lizzy.rs Git - rust.git/commitdiff
fix example code
authorAlexis Beingessner <a.beingessner@gmail.com>
Thu, 30 Jul 2015 00:15:11 +0000 (17:15 -0700)
committerAlexis Beingessner <a.beingessner@gmail.com>
Thu, 30 Jul 2015 00:19:42 +0000 (17:19 -0700)
src/doc/tarpl/borrow-splitting.md
src/doc/tarpl/dropck.md
src/doc/tarpl/leaking.md
src/doc/tarpl/safe-unsafe-meaning.md
src/doc/tarpl/vec-layout.md

index fe5f2343dec59f19b55e17cd66bbf5c1309b4764..123e2baf8fafd5ac0f5a2150b9bf3df27eafed0b 100644 (file)
@@ -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<T> = Option<Box<Node<T>>>;
@@ -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<Self::Item> {
+    fn next_back(&mut self) -> Option<Self::Item> {
         loop {
             match self.0.back_mut().and_then(|node_it| node_it.next_back()) {
                 Some(State::Elem(elem)) => return Some(elem),
index 419c61281d9fc95639f451edde75fd489cc9537a..c75bf8b11794c2afecca427eba51071f6c0ffad6 100644 (file)
@@ -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![]);
 ```
 
index dcb03b1c8b6a0df9ba93235f2ac3e3fe7fead53c..343de99f08ad0270427d3dadc9c0bfdf3e1466f1 100644 (file)
@@ -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
 ```
index 1a4e5b8ffad191bbdf4bbe5659d3ccc5fbab76ea..909308397d717bff7ff172c7d3aa5d477fdc3e2c 100644 (file)
@@ -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
index 325399d622b69910741240bdd8dd453029bcb913..3df63d5249c55efbe4fd3b2724e5dd208d5c3e18 100644 (file)
@@ -12,7 +12,6 @@ pub struct Vec<T> {
     cap: usize,
     len: usize,
 }
-
 # fn main() {}
 ```
 
@@ -69,6 +68,7 @@ impl<T> Deref for Unique<T> {
         unsafe { mem::transmute(&self.ptr) }
     }
 }
+# fn main() {}
 ```
 
 Unfortunately the mechanism for stating that your value is non-zero is