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