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()
+ }
})
}
// 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)
}
--- /dev/null
+// 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)
+}