@@ -62,11 +62,13 @@ macro_rules! panic {
6262/// # Custom Messages
6363///
6464/// This macro has a second form, where a custom panic message can
65- /// be provided with or without arguments for formatting.
65+ /// be provided with or without arguments for formatting. See [`std::fmt`]
66+ /// for syntax for this form.
6667///
6768/// [`panic!`]: macro.panic.html
6869/// [`debug_assert!`]: macro.debug_assert.html
69- /// [testing]: ../book/first-edition/testing.html
70+ /// [testing]: ../book/second-edition/ch11-01-writing-tests.html#checking-results-with-the-assert-macro
71+ /// [`std::fmt`]: ../std/fmt/index.html
7072///
7173/// # Examples
7274///
@@ -252,13 +254,15 @@ macro_rules! debug_assert {
252254/// On panic, this macro will print the values of the expressions with their
253255/// debug representations.
254256///
255- /// Unlike `assert_eq!`, `debug_assert_eq!` statements are only enabled in non
257+ /// Unlike [ `assert_eq!`] , `debug_assert_eq!` statements are only enabled in non
256258/// optimized builds by default. An optimized build will omit all
257259/// `debug_assert_eq!` statements unless `-C debug-assertions` is passed to the
258260/// compiler. This makes `debug_assert_eq!` useful for checks that are too
259261/// expensive to be present in a release build but may be helpful during
260262/// development.
261263///
264+ /// [`assert_eq!`]: ../std/macro.assert_eq.html
265+ ///
262266/// # Examples
263267///
264268/// ```
@@ -277,13 +281,15 @@ macro_rules! debug_assert_eq {
277281/// On panic, this macro will print the values of the expressions with their
278282/// debug representations.
279283///
280- /// Unlike `assert_ne!`, `debug_assert_ne!` statements are only enabled in non
284+ /// Unlike [ `assert_ne!`] , `debug_assert_ne!` statements are only enabled in non
281285/// optimized builds by default. An optimized build will omit all
282286/// `debug_assert_ne!` statements unless `-C debug-assertions` is passed to the
283287/// compiler. This makes `debug_assert_ne!` useful for checks that are too
284288/// expensive to be present in a release build but may be helpful during
285289/// development.
286290///
291+ /// [`assert_ne!`]: ../std/macro.assert_ne.html
292+ ///
287293/// # Examples
288294///
289295/// ```
@@ -300,10 +306,9 @@ macro_rules! debug_assert_ne {
300306/// Helper macro for reducing boilerplate code for matching `Result` together
301307/// with converting downstream errors.
302308///
303- /// Prefer using `?` syntax to `try!`. `?` is built in to the language and is
304- /// more succinct than `try!`. It is the standard method for error propagation.
309+ /// The `?` operator was added to replace `try!` and should be used instead.
305310///
306- /// `try!` matches the given `Result`. In case of the `Ok` variant, the
311+ /// `try!` matches the given [ `Result`] . In case of the `Ok` variant, the
307312/// expression has the value of the wrapped value.
308313///
309314/// In case of the `Err` variant, it retrieves the inner error. `try!` then
@@ -312,7 +317,9 @@ macro_rules! debug_assert_ne {
312317/// error is then immediately returned.
313318///
314319/// Because of the early return, `try!` can only be used in functions that
315- /// return `Result`.
320+ /// return [`Result`].
321+ ///
322+ /// [`Result`]: ../std/result/enum.Result.html
316323///
317324/// # Examples
318325///
@@ -331,20 +338,26 @@ macro_rules! debug_assert_ne {
331338/// }
332339/// }
333340///
341+ /// // The prefered method of quick returning Errors
342+ /// fn write_to_file_question() -> Result<(), MyError> {
343+ /// let mut file = File::create("my_best_friends.txt")?;
344+ /// Ok(())
345+ /// }
346+ ///
347+ /// // The previous method of quick returning Errors
334348/// fn write_to_file_using_try() -> Result<(), MyError> {
335349/// let mut file = try!(File::create("my_best_friends.txt"));
336350/// try!(file.write_all(b"This is a list of my best friends."));
337- /// println!("I wrote to the file");
338351/// Ok(())
339352/// }
353+ ///
340354/// // This is equivalent to:
341355/// fn write_to_file_using_match() -> Result<(), MyError> {
342356/// let mut file = try!(File::create("my_best_friends.txt"));
343357/// match file.write_all(b"This is a list of my best friends.") {
344358/// Ok(v) => v,
345359/// Err(e) => return Err(From::from(e)),
346360/// }
347- /// println!("I wrote to the file");
348361/// Ok(())
349362/// }
350363/// ```
@@ -365,7 +378,7 @@ macro_rules! try {
365378/// formatted according to the specified format string and the result will be passed to the writer.
366379/// The writer may be any value with a `write_fmt` method; generally this comes from an
367380/// implementation of either the [`std::fmt::Write`] or the [`std::io::Write`] trait. The macro
368- /// returns whatever the ' write_fmt' method returns; commonly a [`std::fmt::Result`], or an
381+ /// returns whatever the ` write_fmt` method returns; commonly a [`std::fmt::Result`], or an
369382/// [`io::Result`].
370383///
371384/// See [`std::fmt`] for more information on the format string syntax.
@@ -470,10 +483,20 @@ macro_rules! writeln {
470483/// * Loops that dynamically terminate.
471484/// * Iterators that dynamically terminate.
472485///
486+ /// If the determination that the code is unreachable proves incorrect, the
487+ /// program immediately terminates with a [`panic!`]. The function [`unreachable`],
488+ /// which belongs to the [`std::intrinsics`] module, informs the compilier to
489+ /// optimize the code out of the release version entirely.
490+ ///
491+ /// [`panic!`]: ../std/macro.panic.html
492+ /// [`unreachable`]: ../std/intrinsics/fn.unreachable.html
493+ /// [`std::intrinsics`]: ../std/intrinsics/index.html
494+ ///
473495/// # Panics
474496///
475- /// This will always [panic!](macro.panic.html)
497+ /// This will always [` panic!`]
476498///
499+ /// [`panic!`]: ../std/macro.panic.html
477500/// # Examples
478501///
479502/// Match arms:
@@ -516,13 +539,18 @@ macro_rules! unreachable {
516539 } ) ;
517540}
518541
519- /// A standardized placeholder for marking unfinished code. It panics with the
520- /// message `"not yet implemented"` when executed.
542+ /// A standardized placeholder for marking unfinished code.
543+ ///
544+ /// It panics with the message `"not yet implemented"` when executed.
521545///
522546/// This can be useful if you are prototyping and are just looking to have your
523547/// code typecheck, or if you're implementing a trait that requires multiple
524548/// methods, and you're only planning on using one of them.
525549///
550+ /// # Panics
551+ ///
552+ /// This macro always panics.
553+ ///
526554/// # Examples
527555///
528556/// Here's an example of some in-progress code. We have a trait `Foo`:
0 commit comments