Closed
Description
Pretty printed structures for cfg!(windows)
have trailing commas, which is inconsistent with the debug output format documentation and output on non-windows platforms.
use std::fmt;
struct Foo { bar: u32, baz: Option<u32> }
impl fmt::Debug for Foo {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct("Foo")
.field("bar", &self.bar)
.field("baz", &self.baz)
.finish()
}
}
fn main() {
let cfg_windows = if cfg!(windows) { "true" } else { "false" };
let foo = Foo { bar: 1, baz: Some(1) };
println!("[cfg!(windows) == {}]\n{:?}\n{:#?}", cfg_windows, foo, foo);
}
C:> rustc --version
rustc 1.36.0 (a53f9df32 2019-07-03)
C:> cargo run
Compiling t-debug_struct v0.1.0 (C:\Users\Roy\OneDrive\Projects\rust\t-debug_struct)
Finished dev [unoptimized + debuginfo] target(s) in 0.53s
Running `target\debug\t-debug_struct.exe`
[cfg!(windows) == true]
Foo { bar: 1, baz: Some(1) }
Foo {
bar: 1,
baz: Some(
1,
),
}
$ rustc --version
rustc 1.33.0 (2aa4c46cf 2019-02-28)
$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/t-debug_struct`
[cfg!(windows) == false]
Foo { bar: 1, baz: Some(1) }
Foo {
bar: 1,
baz: Some(
1
)
}
Metadata
Metadata
Assignees
Labels
Area: Documentation for any part of the project, including the compiler, standard library, and toolsCategory: An issue proposing an enhancement or a PR with one.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Relevant to the library API team, which will review and decide on the PR/issue.