diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-08-11 23:45:48 -0400 |
|---|---|---|
| committer | Corey Farwell <coreyf@rwell.org> | 2017-08-12 00:31:54 -0400 |
| commit | ea6f0f060c05da71761ed1cfce5763ddcbe962be (patch) | |
| tree | c9e0ff00006ded3badfb7f52bbc1d330d79e10d8 /src/libstd | |
| parent | 8da3ff3fcc1a86af5984b28e939d74e51956c729 (diff) | |
| download | rust-ea6f0f060c05da71761ed1cfce5763ddcbe962be.tar.gz rust-ea6f0f060c05da71761ed1cfce5763ddcbe962be.zip | |
Demonstrate `include!` with Rust code, not just a string slice literal.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/macros.rs | 17 |
1 files 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 @@ pub mod builtin { /// 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 */ }) } |
