mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 03:38:29 +00:00
Add complete doc example for include_bytes!
.
This commit is contained in:
parent
ea6f0f060c
commit
446ff0d529
@ -478,9 +478,26 @@ pub mod builtin {
|
|||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```ignore (cannot-doctest-external-file-dependency)
|
/// Assume there are two files in the same directory with the following
|
||||||
/// let secret_key = include_bytes!("secret-key.bin");
|
/// contents:
|
||||||
|
///
|
||||||
|
/// File 'spanish.in':
|
||||||
|
///
|
||||||
|
/// ```text
|
||||||
|
/// adiós
|
||||||
/// ```
|
/// ```
|
||||||
|
///
|
||||||
|
/// File 'main.rs':
|
||||||
|
///
|
||||||
|
/// ```ignore (cannot-doctest-external-file-dependency)
|
||||||
|
/// 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")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! include_bytes { ($file:expr) => ({ /* compiler built-in */ }) }
|
macro_rules! include_bytes { ($file:expr) => ({ /* compiler built-in */ }) }
|
||||||
|
Loading…
Reference in New Issue
Block a user