mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Rollup merge of #38457 - frewsxcv:include, r=GuillaumeGomez
Improvements to 'include' macro documentation. None
This commit is contained in:
commit
ced04ff5c6
@ -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 */ }) }
|
||||
|
Loading…
Reference in New Issue
Block a user