rust/tests/target/chains-visual.rs

136 lines
3.0 KiB
Rust
Raw Normal View History

// rustfmt-normalize_comments: true
// rustfmt-single_line_if_else_max_width: 0
2016-04-27 15:08:54 -05:00
// rustfmt-chain_indent: Visual
// Test chain formatting.
fn main() {
// Don't put chains on a single line if it wasn't so in source.
let a = b.c
.d
.1
.foo(|x| x + 1);
2017-03-06 16:28:25 -06:00
bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc.ddddddddddddddddddddddddddd();
2016-04-27 15:08:54 -05:00
bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc
.ddddddddddddddddddddddddddd
.eeeeeeee();
// Test case where first chain element isn't a path, but is shorter than
// the size of a tab.
x().y(|| match cond() {
2017-02-22 13:52:52 -06:00
true => (),
false => (),
});
2016-04-27 15:08:54 -05:00
loong_func().quux(move || if true {
2017-02-22 13:52:52 -06:00
1
} else {
2
});
2016-04-27 15:08:54 -05:00
some_fuuuuuuuuunction().method_call_a(aaaaa, bbbbb, |c| {
let x = c;
x
});
some_fuuuuuuuuunction()
.method_call_a(aaaaa, bbbbb, |c| {
let x = c;
x
})
.method_call_b(aaaaa, bbbbb, |c| {
let x = c;
x
});
fffffffffffffffffffffffffffffffffff(a, {
SCRIPT_TASK_ROOT.with(|root| { *root.borrow_mut() = Some(&script_task); });
2016-04-27 15:08:54 -05:00
});
2017-02-22 13:52:52 -06:00
let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum =
2017-03-06 16:28:25 -06:00
xxxxxxx.map(|x| x + 5).map(|x| x / 2).fold(0, |acc, x| acc + x);
2016-04-27 15:08:54 -05:00
aaaaaaaaaaaaaaaa.map(|x| {
2017-02-22 13:52:52 -06:00
x += 1;
x
})
2016-04-27 15:08:54 -05:00
.filter(some_mod::some_filter)
}
fn floaters() {
let z = Foo {
field1: val1,
field2: val2,
};
let x = Foo {
field1: val1,
field2: val2,
}
.method_call()
.method_call();
let y = if cond {
val1
} else {
val2
}
.method_call();
{
match x {
PushParam => {
// params are 1-indexed
stack.push(mparams[match cur.to_digit(10) {
Some(d) => d as usize - 1,
None => return Err("bad param number".to_owned()),
}]
.clone());
}
}
}
if cond {
some();
} else {
none();
}
.bar()
.baz();
Foo { x: val }
.baz(|| {
2017-02-22 13:52:52 -06:00
force();
multiline();
})
2016-04-27 15:08:54 -05:00
.quux();
Foo {
y: i_am_multi_line,
z: ok,
}
.baz(|| {
2017-02-22 13:52:52 -06:00
force();
multiline();
})
2016-04-27 15:08:54 -05:00
.quux();
a +
match x {
true => "yay!",
false => "boo!",
}
.bar()
}
fn is_replaced_content() -> bool {
2017-03-06 16:28:25 -06:00
constellat.send(ConstellationMsg::ViewportConstrained(self.id, constraints)).unwrap();
2016-04-27 15:08:54 -05:00
}
fn issue587() {
a.b::<()>(c);
std::mem::transmute(dl.symbol::<()>("init").unwrap())
}