panic! 和 assert! 中的捕获

版本新特性 / Rust 1.58

let path = "/etc/app.conf";
let width = 12;

// *** 以前 ***
panic!("cannot read the file {}", path);
assert!(width > 0, "the width {} is wrong", width);
let line = format!("{:>1$}", path, width);

// *** 在 1.58 版本中 ***
panic!("cannot read the file {path}");
assert!(width > 0, "the width {width} is wrong");
let line = format!("{path:>width$}");   // 宽度同样可以按名称传入