diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-08-12 00:25:49 -0400 |
|---|---|---|
| committer | Corey Farwell <coreyf@rwell.org> | 2017-08-12 00:31:56 -0400 |
| commit | 8d0d2a572939b2fba74a59db2de0ad4e30484b43 (patch) | |
| tree | b0bce91a43ec030060dc96c8d5330449852d1aa1 /src/libstd | |
| parent | 446ff0d529ff0d3747bcf11b36dd7c60e6a900d5 (diff) | |
| download | rust-8d0d2a572939b2fba74a59db2de0ad4e30484b43.tar.gz rust-8d0d2a572939b2fba74a59db2de0ad4e30484b43.zip | |
Add complete doc example for `include_str!`.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/macros.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index bc170f8ce1b..c426bf8086e 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -461,9 +461,26 @@ pub mod builtin { /// /// # Examples /// + /// Assume there are two files in the same directory with the following + /// contents: + /// + /// File 'spanish.in': + /// + /// ```text + /// adiós + /// ``` + /// + /// File 'main.rs': + /// /// ```ignore (cannot-doctest-external-file-dependency) - /// let secret_key = include_str!("secret-key.ascii"); + /// fn main() { + /// let my_str = include_str!("spanish.in"); + /// assert_eq!(my_str, "adiós\n"); + /// print!("{}", my_str); + /// } /// ``` + /// + /// Compiling 'main.rs' and running the resulting binary will print "adiós". #[stable(feature = "rust1", since = "1.0.0")] #[macro_export] macro_rules! include_str { ($file:expr) => ({ /* compiler built-in */ }) } |
