Skip to content

Commit 3597677

Browse files
committed
moved renamed docs formatted | log-knows-the-names-of-variants.rs
1 parent cbbc9d4 commit 3597677

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//! Test that `#[derive(Debug)]` for enums correctly formats variant names.
2+
3+
//@ run-pass
4+
5+
#[derive(Debug)]
6+
enum Foo {
7+
A(usize),
8+
C,
9+
}
10+
11+
#[derive(Debug)]
12+
enum Bar {
13+
D,
14+
}
15+
16+
pub fn main() {
17+
// Test variant with data
18+
let foo_a = Foo::A(22);
19+
assert_eq!("A(22)".to_string(), format!("{:?}", foo_a));
20+
21+
if let Foo::A(value) = foo_a {
22+
println!("Value: {}", value); // This needs to remove #[allow(dead_code)]
23+
}
24+
25+
// Test unit variant
26+
assert_eq!("C".to_string(), format!("{:?}", Foo::C));
27+
28+
// Test unit variant from different enum
29+
assert_eq!("D".to_string(), format!("{:?}", Bar::D));
30+
}

tests/ui/log-knows-the-names-of-variants.rs

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)