]> git.lizzy.rs Git - rust.git/blob - tests/target/chains-visual.rs
Merge pull request #1861 from topecongiro/refactor-chain
[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().method_call_a(aaaaa, bbbbb, |c| {
36         let x = c;
37         x
38     })
39                            .method_call_b(aaaaa, bbbbb, |c| {
40         let x = c;
41         x
42     });
43
44     fffffffffffffffffffffffffffffffffff(a, {
45         SCRIPT_TASK_ROOT.with(|root| { *root.borrow_mut() = Some(&script_task); });
46     });
47
48     let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum =
49         xxxxxxx.map(|x| x + 5)
50                .map(|x| x / 2)
51                .fold(0, |acc, x| acc + x);
52
53     aaaaaaaaaaaaaaaa.map(|x| {
54         x += 1;
55         x
56     })
57                     .filter(some_mod::some_filter)
58 }
59
60 fn floaters() {
61     let z = Foo {
62         field1: val1,
63         field2: val2,
64     };
65
66     let x = Foo {
67                 field1: val1,
68                 field2: val2,
69             }.method_call()
70             .method_call();
71
72     let y = if cond {
73                 val1
74             } else {
75                 val2
76             }.method_call();
77
78     {
79         match x {
80             PushParam => {
81                 // params are 1-indexed
82                 stack.push(
83                     mparams[match cur.to_digit(10) {
84                                 Some(d) => d as usize - 1,
85                                 None => return Err("bad param number".to_owned()),
86                             }].clone(),
87                 );
88             }
89         }
90     }
91
92     if cond {
93         some();
94     } else {
95         none();
96     }.bar()
97     .baz();
98
99     Foo { x: val }.baz(|| {
100         force();
101         multiline();
102     })
103                   .quux();
104
105     Foo {
106         y: i_am_multi_line,
107         z: ok,
108     }.baz(|| {
109         force();
110         multiline();
111     })
112     .quux();
113
114     a + match x {
115             true => "yay!",
116             false => "boo!",
117         }.bar()
118 }
119
120 fn is_replaced_content() -> bool {
121     constellat.send(ConstellationMsg::ViewportConstrained(self.id, constraints))
122               .unwrap();
123 }
124
125 fn issue587() {
126     a.b::<()>(c);
127
128     std::mem::transmute(dl.symbol::<()>("init").unwrap())
129 }
130
131 fn issue_1389() {
132     let names = String::from_utf8(names)?.split('|')
133                                          .map(str::to_owned)
134                                          .collect();
135 }
136
137 fn issue1217() -> Result<Mnemonic, Error> {
138     let random_chars: String = OsRng::new()?.gen_ascii_chars()
139                                             .take(self.bit_length)
140                                             .collect();
141
142     Ok(Mnemonic::new(&random_chars))
143 }
144
145 fn issue1236(options: Vec<String>) -> Result<Option<String>> {
146     let process = Command::new("dmenu").stdin(Stdio::piped())
147                                        .stdout(Stdio::piped())
148                                        .spawn()
149                                        .chain_err(|| "failed to spawn dmenu")?;
150 }
151
152 fn issue1434() {
153     for _ in 0..100 {
154         let prototype_id =
155             PrototypeIdData::from_reader::<_, B>(&mut self.file_cursor).chain_err(|| {
156                 format!(
157                     "could not read prototype ID at offset {:#010x}",
158                     current_offset
159                 )
160             })?;
161     }
162 }