From 678e5a8d900c629aabecb118edc8ba0407f58db3 Mon Sep 17 00:00:00 2001 From: Joshua Groves Date: Tue, 8 Jan 2019 13:07:56 -0700 Subject: [PATCH] Run cargo-fmt --- src/bindgen/ir/constant.rs | 21 +++++++++------------ src/bindgen/parser.rs | 34 +++++++++++++++++----------------- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/bindgen/ir/constant.rs b/src/bindgen/ir/constant.rs index fee0c4ad0..794e899fe 100644 --- a/src/bindgen/ir/constant.rs +++ b/src/bindgen/ir/constant.rs @@ -201,23 +201,20 @@ impl Constant { _ => false, }; - if !ty.is_primitive_or_ptr_primitive() && !can_handle_const_expr - { + if !ty.is_primitive_or_ptr_primitive() && !can_handle_const_expr { return Err("Unhandled const definition".to_owned()); } - let expr = Literal::load( - match item.expr { - syn::Expr::Struct(syn::ExprStruct { ref fields, .. }) => { - if is_transparent && fields.len() == 1 { - &fields[0].expr - } else { - &item.expr - } + let expr = Literal::load(match item.expr { + syn::Expr::Struct(syn::ExprStruct { ref fields, .. }) => { + if is_transparent && fields.len() == 1 { + &fields[0].expr + } else { + &item.expr } - _ => &item.expr, } - )?; + _ => &item.expr, + })?; let full_name = Path::new(format!("{}_{}", struct_path, name)); diff --git a/src/bindgen/parser.rs b/src/bindgen/parser.rs index ab728abc2..bb95b96bc 100644 --- a/src/bindgen/parser.rs +++ b/src/bindgen/parser.rs @@ -522,12 +522,10 @@ impl Parse { self.load_syn_ty(crate_name, mod_cfg, item); } syn::Item::Impl(ref item_impl) => { - let has_assoc_const = item_impl.items - .iter() - .any(|item| match item { - syn::ImplItem::Const(_) => true, - _ => false, - }); + let has_assoc_const = item_impl.items.iter().any(|item| match item { + syn::ImplItem::Const(_) => true, + _ => false, + }); if has_assoc_const { impls_with_assoc_consts.push(item_impl); } @@ -537,12 +535,10 @@ impl Parse { } for item_impl in impls_with_assoc_consts { - let associated_constants = item_impl.items - .iter() - .filter_map(|item| match item { - syn::ImplItem::Const(ref associated_constant) => Some(associated_constant), - _ => None, - }); + let associated_constants = item_impl.items.iter().filter_map(|item| match item { + syn::ImplItem::Const(ref associated_constant) => Some(associated_constant), + _ => None, + }); self.load_syn_assoc_consts( binding_crate_name, crate_name, @@ -648,7 +644,10 @@ impl Parse { } } - fn is_assoc_const_of_transparent_struct(&self, const_item: &syn::ImplItemConst) -> Result { + fn is_assoc_const_of_transparent_struct( + &self, + const_item: &syn::ImplItemConst, + ) -> Result { let ty = match Type::load(&const_item.ty) { Ok(Some(t)) => t, _ => return Ok(false), @@ -698,10 +697,11 @@ impl Parse { let impl_path = ty.unwrap().get_root_path().unwrap(); for item in items.into_iter() { - let is_assoc_const_of_transparent_struct = match self.is_assoc_const_of_transparent_struct(&item) { - Ok(b) => b, - Err(_) => continue, - }; + let is_assoc_const_of_transparent_struct = + match self.is_assoc_const_of_transparent_struct(&item) { + Ok(b) => b, + Err(_) => continue, + }; if crate_name != binding_crate_name { info!(