diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2017-01-19 11:56:00 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-19 11:56:00 +0100 |
| commit | ced04ff5c6d4a37ada345ab4d2b4d5a09f12dcb6 (patch) | |
| tree | 93e203b66fc3f8bc6835a38766b8d490b3ad99a4 /src/libstd | |
| parent | 74c42ac173bee900979870ed986c760596d1fbdb (diff) | |
| parent | 4a354abeae973ecf7bd92f35bc786e62a128d6ae (diff) | |
| download | rust-ced04ff5c6d4a37ada345ab4d2b4d5a09f12dcb6.tar.gz rust-ced04ff5c6d4a37ada345ab4d2b4d5a09f12dcb6.zip | |
Rollup merge of #38457 - frewsxcv:include, r=GuillaumeGomez
Improvements to 'include' macro documentation. None
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/macros.rs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 52c6da58151..d79a9a202d9 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -458,23 +458,38 @@ 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 - /// 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. /// /// # 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 */ }) } |
