From b71362e998e761de41c5bb17cbc05b3d2affcee8 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Mon, 19 Jul 2021 14:50:55 +0200 Subject: [PATCH] Improve panic macro consistency summary --- src/rust-2021/panic-macro-consistency.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rust-2021/panic-macro-consistency.md b/src/rust-2021/panic-macro-consistency.md index 9a18801a..ac74e155 100644 --- a/src/rust-2021/panic-macro-consistency.md +++ b/src/rust-2021/panic-macro-consistency.md @@ -2,10 +2,12 @@ ## Summary -- `panic!(..)` now always use `format_args!(..)`, just like `println!()`. +- `panic!(..)` now always uses `format_args!(..)`, just like `println!()`. - `panic!("{")` is no longer accepted, without escaping the `{` as `{{`. - `panic!(x)` is no longer accepted if `x` is not a string literal. -- Use `std::panic::panic_any(x)` to panic with a non-string payload. + - Use `std::panic::panic_any(x)` to panic with a non-string payload. + - Or use `panic!("{}", x)` to use `x`'s `Display` implementation. +- The same applies to `assert!(expr, ..)`. ## Details