fix formatting and merging if chains in attributes (#2697)
* fix formatting and merging if chains in attributes * fix autoformat if attribute chains * Fix IfAttributeValue ToTokens implementation --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
a6e41e9d68
commit
7f210633eb
8 files changed
+301
-145
No files matched your search
@@ -7,7 +7,7 @@ use quote::quote;
|
||||
use quote::{ToTokens, TokenStreamExt};
|
||||
use syn::{
|
||||
parse::{Parse, ParseStream},
|
||||
Expr, ExprIf, Result, Token,
|
||||
Expr, Result, Token,
|
||||
};
|
||||
|
||||
use crate::TemplateBody;
|
||||
@@ -138,21 +138,6 @@ impl ToTokens for IfChain {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn is_if_chain_terminated(chain: &ExprIf) -> bool {
|
||||
let mut current = chain;
|
||||
loop {
|
||||
if let Some((_, else_block)) = ¤t.else_branch {
|
||||
if let Expr::If(else_if) = else_block.as_ref() {
|
||||
current = else_if;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_if_chain() {
|
||||
let input = quote! {
|
||||
|
||||
Reference in new issue
Block a user