Closed
Description
struct S<'a>(&'a str);
impl<'a> std::fmt::Debug for S<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match *self {
// This suggests changing `ref s` to `s`, which won't compile
// (`field` takes a `&Debug`).
S(ref s) => f.debug_tuple("S").field(s).finish()
// I'm aware you can do this.
//S(s) => f.debug_tuple("S").field(&s).finish()
}
}
}
Playground link: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=21db39fed7d5b0778b382e206fa45f1b