From 8a472a55677959639a92d359a23f5e075cd3cbce Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 18 Dec 2016 11:30:56 -0800 Subject: Add a more complete doc example for 'include' macro. --- src/libstd/macros.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 0ce6b0a9431..9908afd900b 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -470,11 +470,26 @@ pub mod builtin { /// /// # Examples /// + /// Assume there are two files in the same directory with the following + /// contents: + /// + /// File 'my_str.in': + /// /// ```ignore - /// fn foo() { - /// include!("/path/to/a/file") + /// "Hello World!" + /// ``` + /// + /// File 'main.rs': + /// + /// ```ignore + /// fn main() { + /// let my_str = include!("my_str.in"); + /// println!("{}", my_str); /// } /// ``` + /// + /// Compiling 'main.rs' and running the resulting binary will print "Hello + /// World!". #[stable(feature = "rust1", since = "1.0.0")] #[macro_export] macro_rules! include { ($file:expr) => ({ /* compiler built-in */ }) } -- cgit 1.4.1-3-g733a5