mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
26 lines
450 B
Rust
26 lines
450 B
Rust
//@ run-rustfix
|
|
enum Enum {
|
|
Variant(i32),
|
|
}
|
|
struct Struct(i32);
|
|
|
|
fn foo(x: Enum) -> i32 {
|
|
let Enum::Variant(value) = x;
|
|
value
|
|
}
|
|
fn bar(x: Enum) -> i32 {
|
|
let Enum::Variant(value) = x;
|
|
let x = value + 1;
|
|
x
|
|
}
|
|
fn baz(x: Struct) -> i32 {
|
|
let Struct(value) = x;
|
|
let x = value + 1;
|
|
x
|
|
}
|
|
fn main() {
|
|
let _ = foo(Enum::Variant(42));
|
|
let _ = bar(Enum::Variant(42));
|
|
let _ = baz(Struct(42));
|
|
}
|