Skip to content

Commit 446ff0d

Browse files
committed
Add complete doc example for include_bytes!.
1 parent ea6f0f0 commit 446ff0d

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
@@ -478,9 +478,26 @@ pub mod builtin {
478478
///
479479
/// # Examples
480480
///
481+
/// Assume there are two files in the same directory with the following
482+
/// contents:
483+
///
484+
/// File 'spanish.in':
485+
///
486+
/// ```text
487+
/// adiós
488+
/// ```
489+
///
490+
/// File 'main.rs':
491+
///
481492
/// ```ignore (cannot-doctest-external-file-dependency)
482-
/// let secret_key = include_bytes!("secret-key.bin");
493+
/// fn main() {
494+
/// let bytes = include_bytes!("spanish.in");
495+
/// assert_eq!(bytes, b"adi\xc3\xb3s\n");
496+
/// print!("{}", String::from_utf8_lossy(bytes));
497+
/// }
483498
/// ```
499+
///
500+
/// Compiling 'main.rs' and running the resulting binary will print "adiós".
484501
#[stable(feature = "rust1", since = "1.0.0")]
485502
#[macro_export]
486503
macro_rules! include_bytes { ($file:expr) => ({ /* compiler built-in */ }) }

0 commit comments

Comments
 (0)