Skip to content

Commit

Permalink
style: simplify string formatting for readability (#169)
Browse files Browse the repository at this point in the history
* style: simplify string formatting for readability

* fix: formatting in `builder_context/types_map.rs`
  • Loading branch information
hamirmahal authored Aug 13, 2024
1 parent 4e57b2a commit 1d74ad0
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/builder_context/filter_types_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 3 additions & 6 deletions src/builder_context/types_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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}'"),
}
}

Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/inputs/filter_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/inputs/order_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/outputs/connection_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/outputs/edge_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/outputs/entity_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1d74ad0

Please sign in to comment.