Add a test for field initialization shorthand
This commit is contained in:
parent
8e6ee4a762
commit
fff59fe8d9
2 changed files with 32 additions and 0 deletions
18
tests/source/init_shorthand.rs
Normal file
18
tests/source/init_shorthand.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Use field initialization shorthand if possible.
|
||||
|
||||
fn main() {
|
||||
let a = Foo {
|
||||
x: x,
|
||||
y: y,
|
||||
z: z,
|
||||
};
|
||||
|
||||
let b = Bar {
|
||||
x: x,
|
||||
y: y,
|
||||
#[attr]
|
||||
z: z,
|
||||
#[rustfmt_skip]
|
||||
skipped: skipped,
|
||||
};
|
||||
}
|
||||
14
tests/target/init_shorthand.rs
Normal file
14
tests/target/init_shorthand.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Use field initialization shorthand if possible.
|
||||
|
||||
fn main() {
|
||||
let a = Foo { x, y, z };
|
||||
|
||||
let b = Bar {
|
||||
x,
|
||||
y,
|
||||
#[attr]
|
||||
z,
|
||||
#[rustfmt_skip]
|
||||
skipped: skipped,
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue