From ea6f0f060c05da71761ed1cfce5763ddcbe962be Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 11 Aug 2017 23:45:48 -0400 Subject: [PATCH] Demonstrate `include!` with Rust code, not just a string slice literal. --- src/libstd/macros.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 5e88a46ecc3..d3e367b815a 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -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::() /// ``` /// /// 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 */ }) } -- 2.44.0