rebasing changes and address review comment
This commit is contained in:
parent
8dfcb9bcdd
commit
d161b8df72
2 changed files with 9 additions and 3 deletions
10
src/expr.rs
10
src/expr.rs
|
@ -162,7 +162,10 @@ impl Rewrite for ast::Expr {
|
||||||
offset))
|
offset))
|
||||||
}
|
}
|
||||||
ast::Expr_::ExprRet(None) => {
|
ast::Expr_::ExprRet(None) => {
|
||||||
wrap_str("return".to_owned(), context.config.max_width, width, offset)
|
wrap_str("return".to_owned(),
|
||||||
|
context.config.max_width,
|
||||||
|
width,
|
||||||
|
offset)
|
||||||
}
|
}
|
||||||
ast::Expr_::ExprRet(Some(ref expr)) => {
|
ast::Expr_::ExprRet(Some(ref expr)) => {
|
||||||
rewrite_unary_prefix(context, "return ", &expr, width, offset)
|
rewrite_unary_prefix(context, "return ", &expr, width, offset)
|
||||||
|
@ -652,7 +655,10 @@ fn single_line_if_else(context: &RewriteContext,
|
||||||
let fits_line = fixed_cost + pat_expr_str.len() + if_str.len() + else_str.len() <= width;
|
let fits_line = fixed_cost + pat_expr_str.len() + if_str.len() + else_str.len() <= width;
|
||||||
|
|
||||||
if fits_line && !if_str.contains('\n') && !else_str.contains('\n') {
|
if fits_line && !if_str.contains('\n') && !else_str.contains('\n') {
|
||||||
return Some(format!("if {} {{ {} }} else {{ {} }}", pat_expr_str, if_str, else_str));
|
return Some(format!("if {} {{ {} }} else {{ {} }}",
|
||||||
|
pat_expr_str,
|
||||||
|
if_str,
|
||||||
|
else_str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub enum ListTactic {
|
||||||
Horizontal,
|
Horizontal,
|
||||||
// Try Horizontal layout, if that fails then vertical
|
// Try Horizontal layout, if that fails then vertical
|
||||||
HorizontalVertical,
|
HorizontalVertical,
|
||||||
// HorizontalVertical with a soft limit.
|
// HorizontalVertical with a soft limit of n characters.
|
||||||
LimitedHorizontalVertical(usize),
|
LimitedHorizontalVertical(usize),
|
||||||
// Pack as many items as possible per row over (possibly) many rows.
|
// Pack as many items as possible per row over (possibly) many rows.
|
||||||
Mixed,
|
Mixed,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue