Skip to content

Commit 8d0d2a5

Browse files
committed
Add complete doc example for include_str!.
1 parent 446ff0d commit 8d0d2a5

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/libstd/macros.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,26 @@ pub mod builtin {
461461
///
462462
/// # Examples
463463
///
464+
/// Assume there are two files in the same directory with the following
465+
/// contents:
466+
///
467+
/// File 'spanish.in':
468+
///
469+
/// ```text
470+
/// adiós
471+
/// ```
472+
///
473+
/// File 'main.rs':
474+
///
464475
/// ```ignore (cannot-doctest-external-file-dependency)
465-
/// let secret_key = include_str!("secret-key.ascii");
476+
/// fn main() {
477+
/// let my_str = include_str!("spanish.in");
478+
/// assert_eq!(my_str, "adiós\n");
479+
/// print!("{}", my_str);
480+
/// }
466481
/// ```
482+
///
483+
/// Compiling 'main.rs' and running the resulting binary will print "adiós".
467484
#[stable(feature = "rust1", since = "1.0.0")]
468485
#[macro_export]
469486
macro_rules! include_str { ($file:expr) => ({ /* compiler built-in */ }) }

0 commit comments

Comments
 (0)