]> git.lizzy.rs Git - rust.git/blob - src/libstd/macros.rs
fix test failures in documentation change
[rust.git] / src / libstd / macros.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! Standard library macros
12 //!
13 //! This modules contains a set of macros which are exported from the standard
14 //! library. Each macro is available for use when linking against the standard
15 //! library.
16
17 #[macro_export]
18 // This stability attribute is totally useless.
19 #[stable(feature = "rust1", since = "1.0.0")]
20 #[cfg(stage0)]
21 macro_rules! __rust_unstable_column {
22     () => {
23         column!()
24     }
25 }
26
27 /// The entry point for panic of Rust threads.
28 ///
29 /// This allows a program to to terminate immediately and provide feedback
30 /// to the caller of the program. `panic!` should be used when a program reaches
31 /// an unrecoverable problem.
32 ///
33 /// This macro is the perfect way to assert conditions in example code and in
34 /// tests.  `panic!` is closely tied with the `unwrap` method of both [`Option`]
35 /// and [`Result`][runwrap] enums.  Both implementations call `panic!` when they are set
36 /// to None or Err variants.
37 ///
38 /// This macro is used to inject panic into a Rust thread, causing the thread to
39 /// panic entirely. Each thread's panic can be reaped as the `Box<Any>` type,
40 /// and the single-argument form of the `panic!` macro will be the value which
41 /// is transmitted.
42 ///
43 /// [`Result`] enum is often a better solution for recovering from errors than
44 /// using the `panic!` macro.  This macro should be used to avoid proceeding using
45 /// incorrect values, such as from external sources.  Detailed information about
46 /// error handling is found in the [book].
47 ///
48 /// The multi-argument form of this macro panics with a string and has the
49 /// [`format!`] syntax for building a string.
50 ///
51 /// [runwrap]: ../std/result/enum.Result.html#method.unwrap
52 /// [`Option`]: ../std/option/enum.Option.html#method.unwrap
53 /// [`Result`]: ../std/result/enum.Result.html
54 /// [`format!`]: ../std/macro.format.html
55 /// [book]: ../book/second-edition/ch09-01-unrecoverable-errors-with-panic.html
56 ///
57 /// # Current implementation
58 ///
59 /// If the main thread panics it will terminate all your threads and end your
60 /// program with code `101`.
61 ///
62 /// # Examples
63 ///
64 /// ```should_panic
65 /// # #![allow(unreachable_code)]
66 /// panic!();
67 /// panic!("this is a terrible mistake!");
68 /// panic!(4); // panic with the value of 4 to be collected elsewhere
69 /// panic!("this is a {} {message}", "fancy", message = "message");
70 /// ```
71 #[macro_export]
72 #[stable(feature = "rust1", since = "1.0.0")]
73 #[allow_internal_unstable]
74 macro_rules! panic {
75     () => ({
76         panic!("explicit panic")
77     });
78     ($msg:expr) => ({
79         $crate::rt::begin_panic($msg, {
80             // static requires less code at runtime, more constant data
81             static _FILE_LINE_COL: (&'static str, u32, u32) = (file!(), line!(),
82                 __rust_unstable_column!());
83             &_FILE_LINE_COL
84         })
85     });
86     ($fmt:expr, $($arg:tt)+) => ({
87         $crate::rt::begin_panic_fmt(&format_args!($fmt, $($arg)+), {
88             // The leading _'s are to avoid dead code warnings if this is
89             // used inside a dead function. Just `#[allow(dead_code)]` is
90             // insufficient, since the user may have
91             // `#[forbid(dead_code)]` and which cannot be overridden.
92             static _FILE_LINE_COL: (&'static str, u32, u32) = (file!(), line!(),
93                 __rust_unstable_column!());
94             &_FILE_LINE_COL
95         })
96     });
97 }
98
99 /// Macro for printing to the standard output.
100 ///
101 /// Equivalent to the [`println!`] macro except that a newline is not printed at
102 /// the end of the message.
103 ///
104 /// Note that stdout is frequently line-buffered by default so it may be
105 /// necessary to use [`io::stdout().flush()`][flush] to ensure the output is emitted
106 /// immediately.
107 ///
108 /// Use `print!` only for the primary output of your program.  Use
109 /// [`eprint!`] instead to print error and progress messages.
110 ///
111 /// [`println!`]: ../std/macro.println.html
112 /// [flush]: ../std/io/trait.Write.html#tymethod.flush
113 /// [`eprint!`]: ../std/macro.eprint.html
114 ///
115 /// # Panics
116 ///
117 /// Panics if writing to `io::stdout()` fails.
118 ///
119 /// # Examples
120 ///
121 /// ```
122 /// use std::io::{self, Write};
123 ///
124 /// print!("this ");
125 /// print!("will ");
126 /// print!("be ");
127 /// print!("on ");
128 /// print!("the ");
129 /// print!("same ");
130 /// print!("line ");
131 ///
132 /// io::stdout().flush().unwrap();
133 ///
134 /// print!("this string has a newline, why not choose println! instead?\n");
135 ///
136 /// io::stdout().flush().unwrap();
137 /// ```
138 #[macro_export]
139 #[stable(feature = "rust1", since = "1.0.0")]
140 #[allow_internal_unstable]
141 macro_rules! print {
142     ($($arg:tt)*) => ($crate::io::_print(format_args!($($arg)*)));
143 }
144
145 /// Macro for printing to the standard output, with a newline.
146 ///
147 /// On all platforms, the newline is the LINE FEED character (`\n`/`U+000A`) alone
148 /// (no additional CARRIAGE RETURN (`\r`/`U+000D`).
149 ///
150 /// Use the [`format!`] syntax to write data to the standard output.
151 /// See [`std::fmt`] for more information.
152 ///
153 /// Use `println!` only for the primary output of your program.  Use
154 /// [`eprintln!`] instead to print error and progress messages.
155 ///
156 /// [`format!`]: ../std/macro.format.html
157 /// [`std::fmt`]: ../std/fmt/index.html
158 /// [`eprintln!`]: ..std/macro.eprint.html
159 /// # Panics
160 ///
161 /// Panics if writing to `io::stdout` fails.
162 ///
163 /// # Examples
164 ///
165 /// ```
166 /// println!(); // prints just a newline
167 /// println!("hello there!");
168 /// println!("format {} arguments", "some");
169 /// ```
170 #[macro_export]
171 #[stable(feature = "rust1", since = "1.0.0")]
172 macro_rules! println {
173     () => (print!("\n"));
174     ($fmt:expr) => (print!(concat!($fmt, "\n")));
175     ($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
176 }
177
178 /// Macro for printing to the standard error.
179 ///
180 /// Equivalent to the [`print!`] macro, except that output goes to
181 /// [`io::stderr`] instead of `io::stdout`.  See [`print!`] for
182 /// example usage.
183 ///
184 /// Use `eprint!` only for error and progress messages.  Use `print!`
185 /// instead for the primary output of your program.
186 ///
187 /// [`io::stderr`]: ../std/io/struct.Stderr.html
188 /// [`print!`]: ../std/macro.print.html
189 ///
190 /// # Panics
191 ///
192 /// Panics if writing to `io::stderr` fails.
193 ///
194 /// # Examples
195 ///
196 /// ```
197 /// eprint!("Error: Could not complete task");
198 /// ```
199 #[macro_export]
200 #[stable(feature = "eprint", since = "1.19.0")]
201 #[allow_internal_unstable]
202 macro_rules! eprint {
203     ($($arg:tt)*) => ($crate::io::_eprint(format_args!($($arg)*)));
204 }
205
206 /// Macro for printing to the standard error, with a newline.
207 ///
208 /// Equivalent to the [`println!`] macro, except that output goes to
209 /// [`io::stderr`] instead of `io::stdout`.  See [`println!`] for
210 /// example usage.
211 ///
212 /// Use `eprintln!` only for error and progress messages.  Use `println!`
213 /// instead for the primary output of your program.
214 ///
215 /// [`io::stderr`]: ../std/io/struct.Stderr.html
216 /// [`println!`]: ../std/macro.println.html
217 ///
218 /// # Panics
219 ///
220 /// Panics if writing to `io::stderr` fails.
221 ///
222 /// # Examples
223 ///
224 /// ```
225 /// eprintln!("Error: Could not complete task");
226 /// ```
227 #[macro_export]
228 #[stable(feature = "eprint", since = "1.19.0")]
229 macro_rules! eprintln {
230     () => (eprint!("\n"));
231     ($fmt:expr) => (eprint!(concat!($fmt, "\n")));
232     ($fmt:expr, $($arg:tt)*) => (eprint!(concat!($fmt, "\n"), $($arg)*));
233 }
234
235 /// A macro to select an event from a number of receivers.
236 ///
237 /// This macro is used to wait for the first event to occur on a number of
238 /// receivers. It places no restrictions on the types of receivers given to
239 /// this macro, this can be viewed as a heterogeneous select.
240 ///
241 /// # Examples
242 ///
243 /// ```
244 /// #![feature(mpsc_select)]
245 ///
246 /// use std::thread;
247 /// use std::sync::mpsc;
248 ///
249 /// // two placeholder functions for now
250 /// fn long_running_thread() {}
251 /// fn calculate_the_answer() -> u32 { 42 }
252 ///
253 /// let (tx1, rx1) = mpsc::channel();
254 /// let (tx2, rx2) = mpsc::channel();
255 ///
256 /// thread::spawn(move|| { long_running_thread(); tx1.send(()).unwrap(); });
257 /// thread::spawn(move|| { tx2.send(calculate_the_answer()).unwrap(); });
258 ///
259 /// select! {
260 ///     _ = rx1.recv() => println!("the long running thread finished first"),
261 ///     answer = rx2.recv() => {
262 ///         println!("the answer was: {}", answer.unwrap());
263 ///     }
264 /// }
265 /// # drop(rx1.recv());
266 /// # drop(rx2.recv());
267 /// ```
268 ///
269 /// For more information about select, see the `std::sync::mpsc::Select` structure.
270 #[macro_export]
271 #[unstable(feature = "mpsc_select", issue = "27800")]
272 macro_rules! select {
273     (
274         $($name:pat = $rx:ident.$meth:ident() => $code:expr),+
275     ) => ({
276         use $crate::sync::mpsc::Select;
277         let sel = Select::new();
278         $( let mut $rx = sel.handle(&$rx); )+
279         unsafe {
280             $( $rx.add(); )+
281         }
282         let ret = sel.wait();
283         $( if ret == $rx.id() { let $name = $rx.$meth(); $code } else )+
284         { unreachable!() }
285     })
286 }
287
288 #[cfg(test)]
289 macro_rules! assert_approx_eq {
290     ($a:expr, $b:expr) => ({
291         let (a, b) = (&$a, &$b);
292         assert!((*a - *b).abs() < 1.0e-6,
293                 "{} is not approximately equal to {}", *a, *b);
294     })
295 }
296
297 /// Built-in macros to the compiler itself.
298 ///
299 /// These macros do not have any corresponding definition with a `macro_rules!`
300 /// macro, but are documented here. Their implementations can be found hardcoded
301 /// into libsyntax itself.
302 #[cfg(dox)]
303 pub mod builtin {
304
305     /// Unconditionally causes compilation to fail with the given error message when encountered.
306     ///
307     /// For more information, see the [RFC].
308     ///
309     /// [RFC]: https://github.com/rust-lang/rfcs/blob/master/text/1695-add-error-macro.md
310     #[stable(feature = "compile_error_macro", since = "1.20.0")]
311     #[macro_export]
312     macro_rules! compile_error { ($msg:expr) => ({ /* compiler built-in */ }) }
313
314     /// The core macro for formatted string creation & output.
315     ///
316     /// This macro functions by taking a formatting string literal containing
317     /// `{}` for each additional argument passed.  `format_args!` prepares the
318     /// additional parameters to ensure the output can be interpreted as a string
319     /// and canonicalizes the arguments into a single type.  Any value that implements
320     /// the [`Display`] trait can be passed to `format_args!`, as can any
321     /// [`Debug`] implementation be passed to a `{:?}` within the formatting string.
322     ///
323     /// This macro produces a value of type [`fmt::Arguments`]. This value can be
324     /// passed to the macros within [`std::fmt`] for performing useful redirection.
325     /// All other formatting macros ([`format!`], [`write!`], [`println!`], etc) are
326     /// proxied through this one.  `format_args!`, unlike its derived macros, avoids
327     /// heap allocations.
328     ///
329     /// For more information, see the documentation in [`std::fmt`].
330     ///
331     /// [`Display`]: ../std/fmt/trait.Display.html
332     /// [`Debug`]: ../std/fmt/trait.Debug.html
333     /// [`fmt::Arguments`]: ../std/fmt/struct.Arguments.html
334     /// [`std::fmt`]: ../std/fmt/index.html
335     /// [`format!`]: ../std/macro.format.html
336     /// [`write!`]: ../std/macro.write.html
337     /// [`println!`]: ../std/macro.println.html
338     ///
339     /// # Examples
340     ///
341     /// ```
342     /// use std::fmt;
343     ///
344     /// let s = fmt::format(format_args!("hello {}", "world"));
345     /// assert_eq!(s, format!("hello {}", "world"));
346     ///
347     /// ```
348     #[stable(feature = "rust1", since = "1.0.0")]
349     #[macro_export]
350     macro_rules! format_args { ($fmt:expr, $($args:tt)*) => ({
351         /* compiler built-in */
352     }) }
353
354     /// Inspect an environment variable at compile time.
355     ///
356     /// This macro will expand to the value of the named environment variable at
357     /// compile time, yielding an expression of type `&'static str`.
358     ///
359     /// If the environment variable is not defined, then a compilation error
360     /// will be emitted.  To not emit a compile error, use the [`option_env!`]
361     /// macro instead.
362     ///
363     /// [`option_env!`]: ../std/macro.option_env.html
364     ///
365     /// # Examples
366     ///
367     /// ```
368     /// let path: &'static str = env!("PATH");
369     /// println!("the $PATH variable at the time of compiling was: {}", path);
370     /// ```
371     #[stable(feature = "rust1", since = "1.0.0")]
372     #[macro_export]
373     macro_rules! env { ($name:expr) => ({ /* compiler built-in */ }) }
374
375     /// Optionally inspect an environment variable at compile time.
376     ///
377     /// If the named environment variable is present at compile time, this will
378     /// expand into an expression of type `Option<&'static str>` whose value is
379     /// `Some` of the value of the environment variable. If the environment
380     /// variable is not present, then this will expand to `None`.  See
381     /// [`Option<T>`][option] for more information on this type.
382     ///
383     /// A compile time error is never emitted when using this macro regardless
384     /// of whether the environment variable is present or not.
385     ///
386     /// [option]: ../std/option/enum.Option.html
387     ///
388     /// # Examples
389     ///
390     /// ```
391     /// let key: Option<&'static str> = option_env!("SECRET_KEY");
392     /// println!("the secret key might be: {:?}", key);
393     /// ```
394     #[stable(feature = "rust1", since = "1.0.0")]
395     #[macro_export]
396     macro_rules! option_env { ($name:expr) => ({ /* compiler built-in */ }) }
397
398     /// Concatenate identifiers into one identifier.
399     ///
400     /// This macro takes any number of comma-separated identifiers, and
401     /// concatenates them all into one, yielding an expression which is a new
402     /// identifier. Note that hygiene makes it such that this macro cannot
403     /// capture local variables. Also, as a general rule, macros are only
404     /// allowed in item, statement or expression position. That means while
405     /// you may use this macro for referring to existing variables, functions or
406     /// modules etc, you cannot define a new one with it.
407     ///
408     /// # Examples
409     ///
410     /// ```
411     /// #![feature(concat_idents)]
412     ///
413     /// # fn main() {
414     /// fn foobar() -> u32 { 23 }
415     ///
416     /// let f = concat_idents!(foo, bar);
417     /// println!("{}", f());
418     ///
419     /// // fn concat_idents!(new, fun, name) { } // not usable in this way!
420     /// # }
421     /// ```
422     #[unstable(feature = "concat_idents_macro", issue = "29599")]
423     #[macro_export]
424     macro_rules! concat_idents {
425         ($($e:ident),*) => ({ /* compiler built-in */ })
426     }
427
428     /// Concatenates literals into a static string slice.
429     ///
430     /// This macro takes any number of comma-separated literals, yielding an
431     /// expression of type `&'static str` which represents all of the literals
432     /// concatenated left-to-right.
433     ///
434     /// Integer and floating point literals are stringified in order to be
435     /// concatenated.
436     ///
437     /// # Examples
438     ///
439     /// ```
440     /// let s = concat!("test", 10, 'b', true);
441     /// assert_eq!(s, "test10btrue");
442     /// ```
443     #[stable(feature = "rust1", since = "1.0.0")]
444     #[macro_export]
445     macro_rules! concat { ($($e:expr),*) => ({ /* compiler built-in */ }) }
446
447     /// A macro which expands to the line number on which it was invoked.
448     ///
449     /// With [`column!`] and [`file!`], these macros provide debugging information for
450     /// developers about the location within the source.
451     ///
452     /// The expanded expression has type `u32`, and the returned line is not
453     /// the invocation of the `line!()` macro itself, but rather the first macro
454     /// invocation leading up to the invocation of the `line!()` macro.
455     ///
456     /// [`column!`]: macro.column.html
457     /// [`file!`]: macro.file.html
458     ///
459     /// # Examples
460     ///
461     /// ```
462     /// let current_line = line!();
463     /// println!("defined on line: {}", current_line);
464     /// ```
465     #[stable(feature = "rust1", since = "1.0.0")]
466     #[macro_export]
467     macro_rules! line { () => ({ /* compiler built-in */ }) }
468
469     /// A macro which expands to the column number on which it was invoked.
470     ///
471     /// With [`line!`] and [`file!`], these macros provide debugging information for
472     /// developers about the location within the source.
473     ///
474     /// The expanded expression has type `u32`, and the returned column is not
475     /// the invocation of the `column!` macro itself, but rather the first macro
476     /// invocation leading up to the invocation of the `column!` macro.
477     ///
478     /// [`line!`]: macro.line.html
479     /// [`file!`]: macro.file.html
480     ///
481     /// # Examples
482     ///
483     /// ```
484     /// let current_col = column!();
485     /// println!("defined on column: {}", current_col);
486     /// ```
487     #[stable(feature = "rust1", since = "1.0.0")]
488     #[macro_export]
489     macro_rules! column { () => ({ /* compiler built-in */ }) }
490
491     /// A macro which expands to the file name from which it was invoked.
492     ///
493     /// With [`line!`] and [`column!`], these macros provide debugging information for
494     /// developers about the location within the source.
495     ///
496     ///
497     /// The expanded expression has type `&'static str`, and the returned file
498     /// is not the invocation of the `file!` macro itself, but rather the
499     /// first macro invocation leading up to the invocation of the `file!`
500     /// macro.
501     ///
502     /// [`line!`]: macro.line.html
503     /// [`column!`]: macro.column.html
504     ///
505     /// # Examples
506     ///
507     /// ```
508     /// let this_file = file!();
509     /// println!("defined in file: {}", this_file);
510     /// ```
511     #[stable(feature = "rust1", since = "1.0.0")]
512     #[macro_export]
513     macro_rules! file { () => ({ /* compiler built-in */ }) }
514
515     /// A macro which stringifies its argument.
516     ///
517     /// This macro will yield an expression of type `&'static str` which is the
518     /// stringification of all the tokens passed to the macro. No restrictions
519     /// are placed on the syntax of the macro invocation itself.
520     ///
521     /// Note that the expanded results of the input tokens may change in the
522     /// future. You should be careful if you rely on the output.
523     ///
524     /// # Examples
525     ///
526     /// ```
527     /// let one_plus_one = stringify!(1 + 1);
528     /// assert_eq!(one_plus_one, "1 + 1");
529     /// ```
530     #[stable(feature = "rust1", since = "1.0.0")]
531     #[macro_export]
532     macro_rules! stringify { ($t:tt) => ({ /* compiler built-in */ }) }
533
534     /// Includes a utf8-encoded file as a string.
535     ///
536     /// The file is located relative to the current file. (similarly to how
537     /// modules are found)
538     ///
539     /// This macro will yield an expression of type `&'static str` which is the
540     /// contents of the file.
541     ///
542     /// # Examples
543     ///
544     /// Assume there are two files in the same directory with the following
545     /// contents:
546     ///
547     /// File 'spanish.in':
548     ///
549     /// ```text
550     /// adiós
551     /// ```
552     ///
553     /// File 'main.rs':
554     ///
555     /// ```ignore (cannot-doctest-external-file-dependency)
556     /// fn main() {
557     ///     let my_str = include_str!("spanish.in");
558     ///     assert_eq!(my_str, "adiós\n");
559     ///     print!("{}", my_str);
560     /// }
561     /// ```
562     ///
563     /// Compiling 'main.rs' and running the resulting binary will print "adiós".
564     #[stable(feature = "rust1", since = "1.0.0")]
565     #[macro_export]
566     macro_rules! include_str { ($file:expr) => ({ /* compiler built-in */ }) }
567
568     /// Includes a file as a reference to a byte array.
569     ///
570     /// The file is located relative to the current file. (similarly to how
571     /// modules are found)
572     ///
573     /// This macro will yield an expression of type `&'static [u8; N]` which is
574     /// the contents of the file.
575     ///
576     /// # Examples
577     ///
578     /// Assume there are two files in the same directory with the following
579     /// contents:
580     ///
581     /// File 'spanish.in':
582     ///
583     /// ```text
584     /// adiós
585     /// ```
586     ///
587     /// File 'main.rs':
588     ///
589     /// ```ignore (cannot-doctest-external-file-dependency)
590     /// fn main() {
591     ///     let bytes = include_bytes!("spanish.in");
592     ///     assert_eq!(bytes, b"adi\xc3\xb3s\n");
593     ///     print!("{}", String::from_utf8_lossy(bytes));
594     /// }
595     /// ```
596     ///
597     /// Compiling 'main.rs' and running the resulting binary will print "adiós".
598     #[stable(feature = "rust1", since = "1.0.0")]
599     #[macro_export]
600     macro_rules! include_bytes { ($file:expr) => ({ /* compiler built-in */ }) }
601
602     /// Expands to a string that represents the current module path.
603     ///
604     /// The current module path can be thought of as the hierarchy of modules
605     /// leading back up to the crate root. The first component of the path
606     /// returned is the name of the crate currently being compiled.
607     ///
608     /// # Examples
609     ///
610     /// ```
611     /// mod test {
612     ///     pub fn foo() {
613     ///         assert!(module_path!().ends_with("test"));
614     ///     }
615     /// }
616     ///
617     /// test::foo();
618     /// ```
619     #[stable(feature = "rust1", since = "1.0.0")]
620     #[macro_export]
621     macro_rules! module_path { () => ({ /* compiler built-in */ }) }
622
623     /// Boolean evaluation of configuration flags.
624     ///
625     /// In addition to the `#[cfg]` attribute, this macro is provided to allow
626     /// boolean expression evaluation of configuration flags. This frequently
627     /// leads to less duplicated code.
628     ///
629     /// The syntax given to this macro is the same syntax as [the `cfg`
630     /// attribute](../book/first-edition/conditional-compilation.html).
631     ///
632     /// # Examples
633     ///
634     /// ```
635     /// let my_directory = if cfg!(windows) {
636     ///     "windows-specific-directory"
637     /// } else {
638     ///     "unix-directory"
639     /// };
640     /// ```
641     #[stable(feature = "rust1", since = "1.0.0")]
642     #[macro_export]
643     macro_rules! cfg { ($($cfg:tt)*) => ({ /* compiler built-in */ }) }
644
645     /// Parse a file as an expression or an item according to the context.
646     ///
647     /// The file is located relative to the current file (similarly to how
648     /// modules are found).
649     ///
650     /// Using this macro is often a bad idea, because if the file is
651     /// parsed as an expression, it is going to be placed in the
652     /// surrounding code unhygienically. This could result in variables
653     /// or functions being different from what the file expected if
654     /// there are variables or functions that have the same name in
655     /// the current file.
656     ///
657     /// # Examples
658     ///
659     /// Assume there are two files in the same directory with the following
660     /// contents:
661     ///
662     /// File 'monkeys.in':
663     ///
664     /// ```ignore (only-for-syntax-highlight)
665     /// ['🙈', '🙊', '🙉']
666     ///     .iter()
667     ///     .cycle()
668     ///     .take(6)
669     ///     .collect::<String>()
670     /// ```
671     ///
672     /// File 'main.rs':
673     ///
674     /// ```ignore (cannot-doctest-external-file-dependency)
675     /// fn main() {
676     ///     let my_string = include!("monkeys.in");
677     ///     assert_eq!("🙈🙊🙉🙈🙊🙉", my_string);
678     ///     println!("{}", my_string);
679     /// }
680     /// ```
681     ///
682     /// Compiling 'main.rs' and running the resulting binary will print
683     /// "🙈🙊🙉🙈🙊🙉".
684     #[stable(feature = "rust1", since = "1.0.0")]
685     #[macro_export]
686     macro_rules! include { ($file:expr) => ({ /* compiler built-in */ }) }
687 }