Skip to content

Commit

Permalink
Fix clippy issues
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
  • Loading branch information
zhiburt committed Aug 1, 2021
1 parent b10b0d3 commit 1870437
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Expand Up @@ -414,7 +414,7 @@ default_table!(f64);

impl<T: fmt::Display, const N: usize> Tabled for [T; N] {
fn fields(&self) -> Vec<String> {
(&self).iter().map(|e| e.to_string()).collect()
self.iter().map(|e| e.to_string()).collect()
}

fn headers() -> Vec<String> {
Expand Down
18 changes: 9 additions & 9 deletions tabled_derive/src/lib.rs
Expand Up @@ -173,13 +173,13 @@ fn get_field_fields(
attrs: &[Attribute],
) -> proc_macro2::TokenStream {
let mut field_value = field;
let is_inline = should_be_inlined(&attrs);
let is_inline = should_be_inlined(attrs);
if is_inline {
let value = quote! { #field_value.fields() };
return value;
}

let func = check_display_with_func(&attrs);
let func = check_display_with_func(attrs);
if let Some(func) = func {
field_value = use_function_for(field_value, &func);
}
Expand Down Expand Up @@ -379,22 +379,22 @@ fn variant_name(v: &Variant) -> String {
}

fn should_be_inlined(attrs: &[Attribute]) -> bool {
let inline_attr = find_name_attribute(&attrs, "header", "inline", look_up_nested_meta_bool)
.or_else(|| find_name_attribute(&attrs, "field", "inline", look_up_nested_meta_bool))
let inline_attr = find_name_attribute(attrs, "header", "inline", look_up_nested_meta_bool)
.or_else(|| find_name_attribute(attrs, "field", "inline", look_up_nested_meta_bool))
.or_else(|| {
find_name_attribute(&attrs, "header", "inline", look_up_nested_flag_str_in_attr)
find_name_attribute(attrs, "header", "inline", look_up_nested_flag_str_in_attr)
.map(|_| true)
})
.or_else(|| {
find_name_attribute(&attrs, "field", "inline", look_up_nested_flag_str_in_attr)
find_name_attribute(attrs, "field", "inline", look_up_nested_flag_str_in_attr)
.map(|_| true)
});
inline_attr == Some(true)
}

fn look_for_inline_prefix(attrs: &[Attribute]) -> String {
find_name_attribute(&attrs, "header", "inline", look_up_nested_flag_str_in_attr)
.or_else(|| find_name_attribute(&attrs, "field", "inline", look_up_nested_flag_str_in_attr))
find_name_attribute(attrs, "header", "inline", look_up_nested_flag_str_in_attr)
.or_else(|| find_name_attribute(attrs, "field", "inline", look_up_nested_flag_str_in_attr))
.unwrap_or_else(|| "".to_owned())
}

Expand All @@ -407,7 +407,7 @@ fn is_ignored_variant(f: &Variant) -> bool {
}

fn attrs_has_ignore_sign(attrs: &[Attribute]) -> bool {
let is_ignored = find_name_attribute(&attrs, "header", "hidden", look_up_nested_meta_bool);
let is_ignored = find_name_attribute(attrs, "header", "hidden", look_up_nested_meta_bool);
is_ignored == Some(true)
}

Expand Down

0 comments on commit 1870437

Please sign in to comment.