Skip to content

Commit

Permalink
chore; remove config.clone in type register
Browse files Browse the repository at this point in the history
  • Loading branch information
beanpuppy committed Feb 15, 2025
1 parent e3b128e commit f3a8a58
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions clorinde/src/type_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,20 +454,28 @@ impl TypeRegistrar {
}

// check if there's a user-defined mapping first
if let Some(mapping) = self.config.clone().get_type_mapping(ty) {
return Ok(match mapping {
TypeMapping::Simple(name) => self.insert(ty, || ClorindeType::Simple {
pg_ty: ty.clone(),
rust_name: name.to_string(),
is_copy: true,
}),
let mapping_result = if let Some(mapping) = self.config.get_type_mapping(ty) {
match mapping {
TypeMapping::Simple(name) => Some((true, name.to_string(), true, true)),
TypeMapping::Detailed {
rust_type,
is_copy,
is_params,
} => {
self.resolve_type(ty, rust_type, query_name, module_info, *is_copy, *is_params)?
}
} => Some((false, rust_type.to_string(), *is_copy, *is_params)),
}
} else {
None
};

if let Some((is_simple, rust_name, is_copy, is_params)) = mapping_result {
return Ok(if is_simple {
self.insert(ty, || ClorindeType::Simple {
pg_ty: ty.clone(),
rust_name,
is_copy: true,
})
} else {
self.resolve_type(ty, &rust_name, query_name, module_info, is_copy, is_params)?
});
}

Expand Down

0 comments on commit f3a8a58

Please sign in to comment.