diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-08-12 00:22:49 -0400 |
|---|---|---|
| committer | Corey Farwell <coreyf@rwell.org> | 2017-08-12 00:31:55 -0400 |
| commit | 446ff0d529ff0d3747bcf11b36dd7c60e6a900d5 (patch) | |
| tree | 7bc851dd54ece1e3b5ecfc8bdea9d508ccce4abb /src/libstd | |
| parent | ea6f0f060c05da71761ed1cfce5763ddcbe962be (diff) | |
| download | rust-446ff0d529ff0d3747bcf11b36dd7c60e6a900d5.tar.gz rust-446ff0d529ff0d3747bcf11b36dd7c60e6a900d5.zip | |
Add complete doc example for `include_bytes!`.
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 d3e367b815a..bc170f8ce1b 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -478,9 +478,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_bytes!("secret-key.bin"); + /// fn main() { + /// let bytes = include_bytes!("spanish.in"); + /// assert_eq!(bytes, b"adi\xc3\xb3s\n"); + /// print!("{}", String::from_utf8_lossy(bytes)); + /// } /// ``` + /// + /// Compiling 'main.rs' and running the resulting binary will print "adiós". #[stable(feature = "rust1", since = "1.0.0")] #[macro_export] macro_rules! include_bytes { ($file:expr) => ({ /* compiler built-in */ }) } |
