]> git.lizzy.rs Git - rust.git/blob - tests/target/chains-visual.rs
Lookup the last element of 'subexpr_list' instead of the first one
[rust.git] / tests / target / chains-visual.rs
1 // rustfmt-normalize_comments: true
2 // rustfmt-single_line_if_else_max_width: 0
3 // rustfmt-chain_indent: Visual
4 // Test chain formatting.
5
6 fn main() {
7     // Don't put chains on a single line if it wasn't so in source.
8     let a = b.c.d.1.foo(|x| x + 1);
9
10     bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc
11                        .ddddddddddddddddddddddddddd();
12
13     bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc
14                        .ddddddddddddddddddddddddddd
15                        .eeeeeeee();
16
17     // Test case where first chain element isn't a path, but is shorter than
18     // the size of a tab.
19     x().y(|| match cond() {
20               true => (),
21               false => (),
22           });
23
24     loong_func().quux(move || if true {
25                           1
26                       } else {
27                           2
28                       });
29
30     some_fuuuuuuuuunction().method_call_a(aaaaa, bbbbb, |c| {
31         let x = c;
32         x
33     });
34
35     some_fuuuuuuuuunction()
36         .method_call_a(aaaaa, bbbbb, |c| {
37             let x = c;
38             x
39         })
40         .method_call_b(aaaaa, bbbbb, |c| {
41             let x = c;
42             x
43         });
44
45     fffffffffffffffffffffffffffffffffff(a, {
46         SCRIPT_TASK_ROOT.with(|root| { *root.borrow_mut() = Some(&script_task); });
47     });
48
49     let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum =
50         xxxxxxx.map(|x| x + 5)
51                .map(|x| x / 2)
52                .fold(0, |acc, x| acc + x);
53
54     aaaaaaaaaaaaaaaa.map(|x| {
55                              x += 1;
56                              x
57                          })
58                     .filter(some_mod::some_filter)
59 }
60
61 fn floaters() {
62     let z = Foo {
63         field1: val1,
64         field2: val2,
65     };
66
67     let x = Foo {
68                 field1: val1,
69                 field2: val2,
70             }
71             .method_call()
72             .method_call();
73
74     let y = if cond {
75                 val1
76             } else {
77                 val2
78             }
79             .method_call();
80
81     {
82         match x {
83             PushParam => {
84                 // params are 1-indexed
85                 stack.push(mparams[match cur.to_digit(10) {
86                                Some(d) => d as usize - 1,
87                                None => return Err("bad param number".to_owned()),
88                            }]
89                            .clone());
90             }
91         }
92     }
93
94     if cond {
95         some();
96     } else {
97         none();
98     }
99     .bar()
100     .baz();
101
102     Foo { x: val }
103         .baz(|| {
104                  force();
105                  multiline();
106              })
107         .quux();
108
109     Foo {
110         y: i_am_multi_line,
111         z: ok,
112     }
113     .baz(|| {
114              force();
115              multiline();
116          })
117     .quux();
118
119     a +
120     match x {
121         true => "yay!",
122         false => "boo!",
123     }
124     .bar()
125 }
126
127 fn is_replaced_content() -> bool {
128     constellat.send(ConstellationMsg::ViewportConstrained(self.id, constraints))
129               .unwrap();
130 }
131
132 fn issue587() {
133     a.b::<()>(c);
134
135     std::mem::transmute(dl.symbol::<()>("init").unwrap())
136 }
137
138 fn issue_1389() {
139     let names = String::from_utf8(names)?
140         .split('|')
141         .map(str::to_owned)
142         .collect();
143 }
144
145 fn issue1217() -> Result<Mnemonic, Error> {
146     let random_chars: String = OsRng::new()?
147         .gen_ascii_chars()
148         .take(self.bit_length)
149         .collect();
150
151     Ok(Mnemonic::new(&random_chars))
152 }
153
154 fn issue1236(options: Vec<String>) -> Result<Option<String>> {
155     let process = Command::new("dmenu")
156         .stdin(Stdio::piped())
157         .stdout(Stdio::piped())
158         .spawn()
159         .chain_err(|| "failed to spawn dmenu")?;
160 }
161
162 fn issue1434() {
163     for _ in 0..100 {
164         let prototype_id = PrototypeIdData::from_reader::<_, B>(&mut self.file_cursor)
165             .chain_err(|| {
166                            format!("could not read prototype ID at offset {:#010x}",
167                                    current_offset)
168                        })?;
169     }
170 }