Rollup merge of #38457 - frewsxcv:include, r=GuillaumeGomez
Improvements to 'include' macro documentation. None
This commit is contained in:
@@ -458,23 +458,38 @@ pub mod builtin {
|
|||||||
|
|
||||||
/// Parse a file as an expression or an item according to the context.
|
/// 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
|
/// The file is located relative to the current file (similarly to how
|
||||||
/// modules are found)
|
/// modules are found).
|
||||||
///
|
///
|
||||||
/// Using this macro is often a bad idea, because if the file is
|
/// 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
|
/// 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
|
/// or functions being different from what the file expected if
|
||||||
/// there are variables or functions that have the same name in
|
/// there are variables or functions that have the same name in
|
||||||
/// the current file.
|
/// the current file.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
/// Assume there are two files in the same directory with the following
|
||||||
|
/// contents:
|
||||||
|
///
|
||||||
|
/// File 'my_str.in':
|
||||||
|
///
|
||||||
/// ```ignore
|
/// ```ignore
|
||||||
/// fn foo() {
|
/// "Hello World!"
|
||||||
/// include!("/path/to/a/file")
|
/// ```
|
||||||
|
///
|
||||||
|
/// 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")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! include { ($file:expr) => ({ /* compiler built-in */ }) }
|
macro_rules! include { ($file:expr) => ({ /* compiler built-in */ }) }
|
||||||
|
|||||||
Reference in New Issue
Block a user