add test and simplify code

This commit is contained in:
Febriananda Wida Pramudita 2024-04-13 22:57:49 +07:00 committed by Yacin Tmimi
parent 22a4306a7e
commit 3854ce9aca
4 changed files with 57 additions and 6 deletions

View File

@ -103,12 +103,9 @@ pub(crate) fn rewrite_match(
let inner_attrs_str = if inner_attrs.is_empty() {
String::new()
} else {
shape.indent.block_indent(context.config);
let result = inner_attrs
.rewrite(context, shape)
.map(|s| format!("{}{}\n", nested_indent_str, s))?;
shape.indent.block_unindent(context.config);
result
inner_attrs
.rewrite(context, shape.block_indent(context.config.tab_spaces()))
.map(|s| format!("{}{}\n", nested_indent_str, s))?
};
let open_brace_pos = if inner_attrs.is_empty() {

View File

@ -0,0 +1,18 @@
pub fn main() {
let a = Some(12)
match a {
#![attr1]
#![attr2]
#![attr3]
_ => None,
}
{
match a {
#![attr1]
#![attr2]
#![attr3]
_ => None,
}
}
}

View File

@ -0,0 +1,18 @@
pub fn main() {
let a = Some(12)
match a {
#![attr1]
#![attr2]
#![attr3]
_ => None,
}
{
match a {
#![attr1]
#![attr2]
#![attr3]
_ => None,
}
}
}

View File

@ -0,0 +1,18 @@
pub fn main() {
let a = Some(12)
match a {
#![attr1]
#![attr2]
#![attr3]
_ => None,
}
{
match a {
#![attr1]
#![attr2]
#![attr3]
_ => None,
}
}
}