]> git.lizzy.rs Git - rust.git/commitdiff
Put rhs on the same line as lhs if putting rhs on next line exceeds max width
authortopecongiro <seuchida@gmail.com>
Fri, 24 Nov 2017 03:05:02 +0000 (12:05 +0900)
committertopecongiro <seuchida@gmail.com>
Fri, 24 Nov 2017 03:05:02 +0000 (12:05 +0900)
src/expr.rs

index ad8cb25b53f6f0abbcb8702e86353a9346f83178..4c651a2bd37ec6853430897400a22e1cf6ab3ca5 100644 (file)
@@ -2632,6 +2632,12 @@ pub fn choose_rhs<R: Rewrite>(
             let new_indent_str = &new_shape.indent.to_string(context.config);
 
             match (orig_rhs, new_rhs) {
+                (Some(ref orig_rhs), Some(ref new_rhs))
+                    if wrap_str(new_rhs.clone(), context.config.max_width(), new_shape)
+                        .is_none() =>
+                {
+                    Some(format!(" {}", orig_rhs))
+                }
                 (Some(ref orig_rhs), Some(ref new_rhs)) if prefer_next_line(orig_rhs, new_rhs) => {
                     Some(format!("\n{}{}", new_indent_str, new_rhs))
                 }