]> git.lizzy.rs Git - rust.git/commitdiff
Fix doctest (fixup \96#25900)
authorManish Goregaokar <manishsmail@gmail.com>
Thu, 4 Jun 2015 05:56:31 +0000 (11:26 +0530)
committerManish Goregaokar <manishsmail@gmail.com>
Thu, 4 Jun 2015 05:56:31 +0000 (11:26 +0530)
src/doc/reference.md

index 045481d7bbd6f3f7ff381a59bb3312d1ac2d4463..d56ecb360cfed3ccd675813feaee24f0b7547518 100644 (file)
@@ -3699,28 +3699,29 @@ Coercion is allowed between the following types:
 * `&mut T` to `*mut T`.
 
 * `&T` to `&U` if `T` implements `Deref<Target = U>`. For example:
-    ```
-    use std::ops::Deref;
 
-    struct CharContainer {
-        value: char
-    }
+```rust
+use std::ops::Deref;
 
-    impl Deref for CharContainer {
-        type Target = char;
+struct CharContainer {
+    value: char
+}
 
-        fn deref<'a>(&'a self) -> &'a char {
-            &self.value
-        }
+impl Deref for CharContainer {
+    type Target = char;
+
+    fn deref<'a>(&'a self) -> &'a char {
+        &self.value
     }
+}
 
-    fn foo(arg: &char) {}
+fn foo(arg: &char) {}
 
-    fn main() {
-        let x = &mut CharContainer { value: 'y' };
-        foo(x); //&mut CharContainer is coerced to &char.
-    }
-    ```
+fn main() {
+    let x = &mut CharContainer { value: 'y' };
+    foo(x); //&mut CharContainer is coerced to &char.
+}
+```
 * `&mut T` to `&mut U` if `T` implements `DerefMut<Target = U>`.
 
 * TyCtor(`T`) to TyCtor(coerce_inner(`T`)), where TyCtor(`T`) is one of