]> git.lizzy.rs Git - rust.git/commitdiff
Format source codes and add a test
authortopecongiro <seuchida@gmail.com>
Thu, 15 Jun 2017 14:29:46 +0000 (23:29 +0900)
committertopecongiro <seuchida@gmail.com>
Thu, 15 Jun 2017 22:36:31 +0000 (07:36 +0900)
src/expr.rs
src/imports.rs
tests/target/issue-1681.rs [new file with mode: 0644]

index 61cd9ad0cfca530b2c978c96af5dfb782ad3806f..22f963e0609f97c686358cfba21933daab450d6e 100644 (file)
@@ -750,14 +750,14 @@ fn and_one_line(x: Option<String>) -> Option<String> {
 
 fn nop_block_collapse(block_str: Option<String>, budget: usize) -> Option<String> {
     debug!("nop_block_collapse {:?} {}", block_str, budget);
-    block_str.map(|block_str| if block_str.starts_with('{') && budget >= 2 &&
-        (block_str[1..]
-             .find(|c: char| !c.is_whitespace())
-             .unwrap() == block_str.len() - 2)
-    {
-        "{}".to_owned()
-    } else {
-        block_str.to_owned()
+    block_str.map(|block_str| {
+        if block_str.starts_with('{') && budget >= 2 &&
+            (block_str[1..].find(|c: char| !c.is_whitespace()).unwrap() == block_str.len() - 2)
+        {
+            "{}".to_owned()
+        } else {
+            block_str.to_owned()
+        }
     })
 }
 
index 3b7c47f0fca65307f62682fbd3d1620edc231ab1..e3c06ae7956b92eea551b7bcdb6430c581df99d8 100644 (file)
@@ -159,9 +159,9 @@ impl Rewrite for ast::ViewPath {
     // Returns an empty string when the ViewPath is empty (like foo::bar::{})
     fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
         match self.node {
-            ast::ViewPath_::ViewPathList(_, ref path_list) if path_list.is_empty() => {
-                Some(String::new())
-            }
+            ast::ViewPath_::ViewPathList(_, ref path_list) if path_list.is_empty() => Some(
+                String::new(),
+            ),
             ast::ViewPath_::ViewPathList(ref path, ref path_list) => {
                 rewrite_use_list(shape, path, path_list, self.span, context)
             }
diff --git a/tests/target/issue-1681.rs b/tests/target/issue-1681.rs
new file mode 100644 (file)
index 0000000..a13f323
--- /dev/null
@@ -0,0 +1,19 @@
+// rustfmt-max_width: 80
+
+fn foo() {
+    // This is where it gets good
+    refmut_map_result(self.cache.borrow_mut(), |cache| {
+        match cache.entry(cache_key) {
+            Occupied(entry) => Ok(entry.into_mut()),
+            Vacant(entry) => {
+                let statement = {
+                    let sql = try!(entry.key().sql(source));
+                    prepare_fn(&sql)
+                };
+
+                Ok(entry.insert(try!(statement)))
+            }
+            // and now, casually call a method on this
+        }
+    }).map(MaybeCached::Cached)
+}