]> git.lizzy.rs Git - rust.git/commitdiff
Demonstrate `include!` with Rust code, not just a string slice literal.
authorCorey Farwell <coreyf@rwell.org>
Sat, 12 Aug 2017 03:45:48 +0000 (23:45 -0400)
committerCorey Farwell <coreyf@rwell.org>
Sat, 12 Aug 2017 04:31:54 +0000 (00:31 -0400)
src/libstd/macros.rs

index 5e88a46ecc343016b947bb896a01b0e0d00e96aa..d3e367b815acb65a0dd3e8d5e776d9551ea2efda 100644 (file)
@@ -545,23 +545,28 @@ macro_rules! cfg { ($($cfg:tt)*) => ({ /* compiler built-in */ }) }
     /// Assume there are two files in the same directory with the following
     /// contents:
     ///
-    /// File 'my_str.in':
+    /// File 'monkeys.in':
     ///
     /// ```ignore (only-for-syntax-highlight)
-    /// "Hello World!"
+    /// ['🙈', '🙊', '🙉']
+    ///     .iter()
+    ///     .cycle()
+    ///     .take(6)
+    ///     .collect::<String>()
     /// ```
     ///
     /// File 'main.rs':
     ///
     /// ```ignore (cannot-doctest-external-file-dependency)
     /// fn main() {
-    ///     let my_str = include!("my_str.in");
-    ///     println!("{}", my_str);
+    ///     let my_string = include!("monkeys.in");
+    ///     assert_eq!("🙈🙊🙉🙈🙊🙉", my_string);
+    ///     println!("{}", my_string);
     /// }
     /// ```
     ///
-    /// Compiling 'main.rs' and running the resulting binary will print "Hello
-    /// World!".
+    /// Compiling 'main.rs' and running the resulting binary will print
+    /// "🙈🙊🙉🙈🙊🙉".
     #[stable(feature = "rust1", since = "1.0.0")]
     #[macro_export]
     macro_rules! include { ($file:expr) => ({ /* compiler built-in */ }) }