]> git.lizzy.rs Git - rust.git/blob - tests/source/chains-visual.rs
Tidy up and pass tests
[rust.git] / tests / source / 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
8     .d.1
9                 .foo(|x| x + 1);
10
11     bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc
12                        .ddddddddddddddddddddddddddd();
13
14     bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc.ddddddddddddddddddddddddddd.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()
19         .y(|| match cond() { true => (), false => () });
20
21     loong_func()
22         .quux(move || if true {
23             1
24         } else {
25             2
26         });
27
28     some_fuuuuuuuuunction()
29         .method_call_a(aaaaa, bbbbb, |c| {
30             let x = c;
31             x
32         });
33
34     some_fuuuuuuuuunction().method_call_a(aaaaa, bbbbb, |c| {
35         let x = c;
36         x
37     }).method_call_b(aaaaa, bbbbb, |c| {
38         let x = c;
39         x
40     });
41
42     fffffffffffffffffffffffffffffffffff(a,
43                                         {
44                                             SCRIPT_TASK_ROOT
45                                             .with(|root| {
46                                                 *root.borrow_mut()  =   Some(&script_task);
47                                             });
48                                         });                                        
49
50     let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum = xxxxxxx
51         .map(|x| x + 5)
52         .map(|x| x / 2)
53         .fold(0, |acc, x| acc + x);
54
55     aaaaaaaaaaaaaaaa.map(|x| {
56                          x += 1;
57                          x
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     }.method_call().method_call();
71
72     let y = if cond {
73                 val1
74             } else {
75                 val2
76             }
77                 .method_call();
78
79     {
80         match x {
81             PushParam => {
82                 // params are 1-indexed
83                 stack.push(mparams[match cur.to_digit(10) {
84                     Some(d) => d as usize - 1,
85                     None => return Err("bad param number".to_owned()),
86                 }]
87                                .clone());
88             }
89         }
90     }
91
92     if cond { some(); } else { none(); }
93         .bar()
94         .baz();
95
96     Foo { x: val } .baz(|| { force(); multiline();    }) .quux(); 
97
98     Foo { y: i_am_multi_line, z: ok }
99         .baz(|| {
100             force(); multiline();
101         })
102         .quux(); 
103
104     a + match x { true => "yay!", false => "boo!" }.bar()
105 }
106
107 fn is_replaced_content() -> bool {
108     constellat.send(ConstellationMsg::ViewportConstrained(
109             self.id, constraints)).unwrap();
110 }
111
112 fn issue587() {
113     a.b::<()>(c);
114
115     std::mem::transmute(dl.symbol::<()>("init").unwrap())
116 }
117
118 fn issue_1389() {
119     let names = String::from_utf8(names)?.split('|').map(str::to_owned).collect();
120 }
121
122 fn issue1217() -> Result<Mnemonic, Error> {
123 let random_chars: String = OsRng::new()?
124     .gen_ascii_chars()
125     .take(self.bit_length)
126     .collect();
127
128     Ok(Mnemonic::new(&random_chars))
129 }
130
131 fn issue1236(options: Vec<String>) -> Result<Option<String>> {
132 let process = Command::new("dmenu").stdin(Stdio::piped())
133     .stdout(Stdio::piped())
134     .spawn()
135     .chain_err(|| "failed to spawn dmenu")?;
136 }
137
138 fn issue1434() {
139     for _ in 0..100 {
140         let prototype_id = 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 }
146
147 fn issue2264() {
148     {
149         something.function()
150             .map(|| {
151                 if let a_very_very_very_very_very_very_very_very_long_variable =
152                     compute_this_variable()
153                 {
154                     println!("Hello");
155                 }
156             })
157             .collect();
158     }
159 }