Skip to content

Commit

Permalink
fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed Jun 28, 2024
1 parent 450f3c3 commit b02653f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions mdmodels-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub fn parse_mdmodel(input: TokenStream) -> TokenStream {
for attribute in object.attributes {
let field_name = syn::Ident::new(&attribute.name, proc_macro2::Span::call_site());
let field_type = get_data_type(&attribute.dtypes[0])
.expect(format!("Unknown data type: {}", attribute.dtypes[0]).as_str());
.unwrap_or_else(|_| panic!("Unknown data type: {}", attribute.dtypes[0]));
let wrapped_type = wrap_dtype(attribute.is_array, attribute.required, field_type);

fields.push(quote! {
Expand Down Expand Up @@ -117,7 +117,7 @@ fn get_data_type(dtype: &str) -> Result<DataTypes, Box<dyn Error>> {

// Function to wrap data types based on their properties (array, required)
fn wrap_dtype(is_array: bool, required: bool, dtype: DataTypes) -> proc_macro2::TokenStream {
let token_stream = match dtype {
match dtype {
DataTypes::BaseType(base_type) => {
if required && !is_array {
quote! { #base_type }
Expand All @@ -140,9 +140,7 @@ fn wrap_dtype(is_array: bool, required: bool, dtype: DataTypes) -> proc_macro2::
quote! { Option<Vec<#complex_type>> }
}
}
};

token_stream
}
}

fn to_snake(name: String) -> String {
Expand Down

0 comments on commit b02653f

Please sign in to comment.