From 8a472a55677959639a92d359a23f5e075cd3cbce Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 18 Dec 2016 11:30:56 -0800 Subject: [PATCH 1/3] Add a more complete doc example for 'include' macro. --- src/libstd/macros.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 0ce6b0a9431d4..9908afd900bfc 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 */ }) } From 44c2eb9182a74025a486ad3e219134c4e3ae160a Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 18 Dec 2016 11:33:37 -0800 Subject: [PATCH 2/3] Move parenthesized statement within sentence. --- src/libstd/macros.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 9908afd900bfc..a79b9f75b7e76 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -458,8 +458,8 @@ pub mod builtin { /// Parse a file as an expression or an item according to the context. /// - /// The file is located relative to the current file. (similarly to how - /// modules are found) + /// The file is located relative to the current file (similarly to how + /// modules are found). /// /// Using this macro is often a bad idea, because if the file is /// parsed as an expression, it is going to be placed in the From 4a354abeae973ecf7bd92f35bc786e62a128d6ae Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 21 Dec 2016 10:44:54 -0800 Subject: [PATCH 3/3] Fix 'unhygienically' typo. --- src/libstd/macros.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index a79b9f75b7e76..d160a68cfc1f1 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -463,7 +463,7 @@ pub mod builtin { /// /// Using this macro is often a bad idea, because if the file is /// parsed as an expression, it is going to be placed in the - /// surrounding code unhygenically. This could result in variables + /// surrounding code unhygienically. This could result in variables /// or functions being different from what the file expected if /// there are variables or functions that have the same name in /// the current file.