Return list if StringArray

This commit is contained in:
Joel Wachsler 2022-07-15 00:39:10 +00:00
parent 5705f29f1a
commit 308a0153ab
2 changed files with 6 additions and 2 deletions

View File

@ -118,7 +118,7 @@ fn generate_builder_field(
None => parameter.return_type.to_owned_type(),
};
let rtype = util::to_ident(&enum_name);
let rtype_as_quote = if parameter.return_type.get_type_info().is_list {
let rtype_as_quote = if parameter.return_type.is_list() {
quote! { std::vec::Vec<#rtype> }
} else {
quote! { #rtype }

View File

@ -15,7 +15,7 @@ pub struct TypeDescription {
pub struct TypeInfo {
pub name: String,
pub is_optional: bool,
pub is_list: bool,
is_list: bool,
pub description: Option<String>,
pub type_description: Option<TypeDescription>,
}
@ -63,6 +63,10 @@ impl Type {
}
}
pub fn is_list(&self) -> bool {
self.get_type_info().is_list || matches!(self, Type::StringArray(_))
}
pub fn to_borrowed_type(&self) -> String {
match self {
Type::Number(_) => "i32".into(),