From 1d74ad0b58e98761f2841505d7a1687d5b4cfa63 Mon Sep 17 00:00:00 2001 From: Hamir Mahal Date: Tue, 13 Aug 2024 03:33:05 -0700 Subject: [PATCH] style: simplify string formatting for readability (#169) * style: simplify string formatting for readability * fix: formatting in `builder_context/types_map.rs` --- src/builder_context/filter_types_map.rs | 4 ++-- src/builder_context/types_map.rs | 9 +++------ src/inputs/filter_input.rs | 2 +- src/inputs/order_input.rs | 2 +- src/outputs/connection_object.rs | 2 +- src/outputs/edge_object.rs | 2 +- src/outputs/entity_object.rs | 2 +- 7 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/builder_context/filter_types_map.rs b/src/builder_context/filter_types_map.rs index c5b00dcf..2282e513 100644 --- a/src/builder_context/filter_types_map.rs +++ b/src/builder_context/filter_types_map.rs @@ -180,7 +180,7 @@ impl FilterTypesMapHelper { .context .filter_types .overwrites - .get(&format!("{}.{}", entity_name, column_name)) + .get(&format!("{entity_name}.{column_name}")) { return ty.clone(); } @@ -426,7 +426,7 @@ impl FilterTypesMapHelper { .context .filter_types .condition_functions - .get(&format!("{}.{}", entity_name, column_name)) + .get(&format!("{entity_name}.{column_name}")) { return filter_condition_fn(condition, filter); } else { diff --git a/src/builder_context/types_map.rs b/src/builder_context/types_map.rs index 6397486a..fdc61ce2 100644 --- a/src/builder_context/types_map.rs +++ b/src/builder_context/types_map.rs @@ -77,7 +77,7 @@ impl TypesMapHelper { column_type: &ColumnType, ) -> ConvertedType { let context = self.context; - let name = format!("{}.{}", entity_name, column_name); + let name = format!("{entity_name}.{column_name}"); if let Some(overwrite) = context.types.overwrites.get(&name) { return overwrite.clone(); @@ -195,10 +195,7 @@ impl TypesMapHelper { ColumnType::MacAddr => ConvertedType::String, // #[cfg(feature = "with-mac_address")] // ColumnType::MacAddr => ConvertedType::MacAddress, - _ => panic!( - "Type mapping is not implemented for '{}.{}'", - entity_name, column_name - ), + _ => panic!("Type mapping is not implemented for '{entity_name}.{column_name}'"), } } @@ -222,7 +219,7 @@ impl TypesMapHelper { .context .types .input_conversions - .get(&format!("{}.{}", entity_name, column_name)) + .get(&format!("{entity_name}.{column_name}")) { return parser.as_ref()(value); } diff --git a/src/inputs/filter_input.rs b/src/inputs/filter_input.rs index e543831c..d591e3c3 100644 --- a/src/inputs/filter_input.rs +++ b/src/inputs/filter_input.rs @@ -13,7 +13,7 @@ impl std::default::Default for FilterInputConfig { fn default() -> Self { FilterInputConfig { type_name: Box::new(|object_name: &str| -> String { - format!("{}FilterInput", object_name) + format!("{object_name}FilterInput") }), } } diff --git a/src/inputs/order_input.rs b/src/inputs/order_input.rs index 51382d16..f1bfeb69 100644 --- a/src/inputs/order_input.rs +++ b/src/inputs/order_input.rs @@ -13,7 +13,7 @@ impl std::default::Default for OrderInputConfig { fn default() -> Self { OrderInputConfig { type_name: Box::new(|object_name: &str| -> String { - format!("{}OrderInput", object_name) + format!("{object_name}OrderInput") }), } } diff --git a/src/outputs/connection_object.rs b/src/outputs/connection_object.rs index a01b16de..e894fa6b 100644 --- a/src/outputs/connection_object.rs +++ b/src/outputs/connection_object.rs @@ -40,7 +40,7 @@ impl std::default::Default for ConnectionObjectConfig { fn default() -> Self { ConnectionObjectConfig { type_name: Box::new(|object_name: &str| -> String { - format!("{}Connection", object_name) + format!("{object_name}Connection") }), page_info: "pageInfo".into(), pagination_info: "paginationInfo".into(), diff --git a/src/outputs/edge_object.rs b/src/outputs/edge_object.rs index 358ac749..459637a7 100644 --- a/src/outputs/edge_object.rs +++ b/src/outputs/edge_object.rs @@ -30,7 +30,7 @@ pub struct EdgeObjectConfig { impl std::default::Default for EdgeObjectConfig { fn default() -> EdgeObjectConfig { EdgeObjectConfig { - type_name: Box::new(|object_name: &str| -> String { format!("{}Edge", object_name) }), + type_name: Box::new(|object_name: &str| -> String { format!("{object_name}Edge") }), cursor: "cursor".into(), node: "node".into(), } diff --git a/src/outputs/entity_object.rs b/src/outputs/entity_object.rs index 96509f25..fbc3789f 100644 --- a/src/outputs/entity_object.rs +++ b/src/outputs/entity_object.rs @@ -139,7 +139,7 @@ impl EntityObjectBuilder { .context .types .output_conversions - .get(&format!("{}.{}", entity_name, column_name)); + .get(&format!("{entity_name}.{column_name}")); let field = Field::new(column_name, graphql_type, move |ctx| { let guard_flag = if let Some(guard) = guard {