Fix formatter inconsistency with record spread patterns.
This commit is contained in:
parent
17431daaa4
commit
814157dd7b
|
@ -839,7 +839,7 @@ impl<'comments> Formatter<'comments> {
|
|||
|
||||
if args.is_empty() && with_spread {
|
||||
if is_record {
|
||||
name.append("{..}")
|
||||
name.append(" { .. }")
|
||||
} else {
|
||||
name.append("(..)")
|
||||
}
|
||||
|
|
|
@ -748,3 +748,25 @@ fn format_pipe_fn() {
|
|||
|
||||
assert_fmt(src, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn match_record() {
|
||||
let src = indoc! { r#"
|
||||
fn foo() {
|
||||
when bar is {
|
||||
Bar { a, b, c } ->
|
||||
Void
|
||||
Bar { a, .. } ->
|
||||
Void
|
||||
Bar { .. } ->
|
||||
Void
|
||||
Bar(a, b, c) ->
|
||||
Void
|
||||
Bar(..) ->
|
||||
Void
|
||||
}
|
||||
}
|
||||
"#};
|
||||
|
||||
assert_fmt(src, src);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ pub fn size(t: MerkleTree) -> Int {
|
|||
when t is {
|
||||
Empty ->
|
||||
0
|
||||
Leaf{..} ->
|
||||
Leaf { .. } ->
|
||||
1
|
||||
Node { left, right, .. } ->
|
||||
size(left) + size(right)
|
||||
|
|
|
@ -139,7 +139,7 @@ pub fn size(self: MerkleTree<a>) -> Int {
|
|||
when self is {
|
||||
Empty ->
|
||||
0
|
||||
Leaf{..} ->
|
||||
Leaf { .. } ->
|
||||
1
|
||||
Node { left, right, .. } ->
|
||||
size(left) + size(right)
|
||||
|
|
|
@ -44,7 +44,7 @@ pub fn size(self: MerkleTree<a>) -> Int {
|
|||
when self is {
|
||||
Empty ->
|
||||
0
|
||||
Leaf{..} ->
|
||||
Leaf { .. } ->
|
||||
1
|
||||
Node { left, right, .. } ->
|
||||
size(left) + size(right)
|
||||
|
|
Loading…
Reference in New Issue