]> git.lizzy.rs Git - rust.git/blob - tests/source/struct_lits.rs
Prevent nested if-else from being put on a single line.
[rust.git] / tests / source / struct_lits.rs
1 // Struct literal expressions.
2
3 fn main() {
4     let x = Bar;
5
6     // Comment
7     let y = Foo {a: x };
8
9     Foo { a: foo() /* comment*/, /* comment*/ b: bar(), ..something };
10
11     Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo { a: foo(), b: bar(), };
12
13     Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo { a: foo(), b: bar(), };
14
15     Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo {
16         // Comment
17         a: foo(), // Comment
18         // Comment
19         b: bar(), // Comment
20     };
21
22     Foo { a:Bar,
23           b:foo() };
24
25     Quux { x: if cond { bar(); }, y: baz() };
26
27     A { 
28     // Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor.
29     first: item(),
30         // Praesent et diam eget libero egestas mattis sit amet vitae augue.
31         // Nam tincidunt congue enim, ut porta lorem lacinia consectetur.
32         second: Item
33     };
34
35     Diagram { /*                 o        This graph demonstrates how                  
36                *                / \       significant whitespace is           
37                *               o   o      preserved.  
38                *              /|\   \
39                *             o o o   o */
40               graph: G, }
41 }
42
43 fn matcher() {
44     TagTerminatedByteMatcher {
45         matcher: ByteMatcher {
46         pattern: b"<HTML",
47         mask: b"\xFF\xDF\xDF\xDF\xDF\xFF",
48     },
49     };
50 }
51
52 fn issue177() {
53     struct Foo<T> { memb: T }
54     let foo = Foo::<i64> { memb: 10 };
55 }