Skip to content

Commit d7e96ff

Browse files
author
daniel.eades
committed
use inline format args (clippy::uninlined_format_args)
1 parent d06dfff commit d7e96ff

File tree

15 files changed

+39
-55
lines changed

15 files changed

+39
-55
lines changed

examples/github/examples/github.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn main() -> Result<(), anyhow::Error> {
5252
.default_headers(
5353
std::iter::once((
5454
reqwest::header::AUTHORIZATION,
55-
reqwest::header::HeaderValue::from_str(&format!("Bearer {}", github_api_token))
55+
reqwest::header::HeaderValue::from_str(&format!("Bearer {github_api_token}"))
5656
.unwrap(),
5757
))
5858
.collect(),

examples/web/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async fn load_more() -> Result<JsValue, JsValue> {
3636
let response = post_graphql::<PuppySmiles, _>(&client, url, variables)
3737
.await
3838
.map_err(|err| {
39-
log(&format!("Could not fetch puppies. error: {:?}", err));
39+
log(&format!("Could not fetch puppies. error: {err:?}"));
4040
JsValue::NULL
4141
})?;
4242
render_response(response);
@@ -77,7 +77,7 @@ fn add_load_more_button() {
7777
fn render_response(response: graphql_client::Response<puppy_smiles::ResponseData>) {
7878
use std::fmt::Write;
7979

80-
log(&format!("response body\n\n{:?}", response));
80+
log(&format!("response body\n\n{response:?}"));
8181

8282
let parent = document().body().expect_throw("no body");
8383

@@ -116,8 +116,7 @@ fn render_response(response: graphql_client::Response<puppy_smiles::ResponseData
116116
.expect_throw("write to string");
117117
}
118118
response.set_inner_html(&format!(
119-
"<h2>response:</h2><div class=\"container\"><div class=\"row\">{}</div></div>",
120-
inner_html
119+
"<h2>response:</h2><div class=\"container\"><div class=\"row\">{inner_html}</div></div>"
121120
));
122121
parent
123122
.append_child(&response)

graphql_client/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ pub enum PathFragment {
122122
impl Display for PathFragment {
123123
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
124124
match *self {
125-
PathFragment::Key(ref key) => write!(f, "{}", key),
126-
PathFragment::Index(ref idx) => write!(f, "{}", idx),
125+
PathFragment::Key(ref key) => write!(f, "{key}"),
126+
PathFragment::Index(ref idx) => write!(f, "{idx}"),
127127
}
128128
}
129129
}
@@ -217,7 +217,7 @@ impl Display for Error {
217217
fragments
218218
.iter()
219219
.fold(String::new(), |mut acc, item| {
220-
let _ = write!(acc, "{}/", item);
220+
let _ = write!(acc, "{item}/");
221221
acc
222222
})
223223
.trim_end_matches('/')

graphql_client/tests/extern_enums.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub struct MultipleExternEnumsQuery;
5050
fn single_extern_enum() {
5151
const RESPONSE: &str = include_str!("extern_enums/single_extern_enum_response.json");
5252

53-
println!("{:?}", RESPONSE);
53+
println!("{RESPONSE:?}");
5454
let response_data: single_extern_enum_query::ResponseData =
5555
serde_json::from_str(RESPONSE).unwrap();
5656

@@ -67,11 +67,11 @@ fn single_extern_enum() {
6767
fn multiple_extern_enums() {
6868
const RESPONSE: &str = include_str!("extern_enums/multiple_extern_enums_response.json");
6969

70-
println!("{:?}", RESPONSE);
70+
println!("{RESPONSE:?}");
7171
let response_data: multiple_extern_enums_query::ResponseData =
7272
serde_json::from_str(RESPONSE).unwrap();
7373

74-
println!("{:?}", response_data);
74+
println!("{response_data:?}");
7575

7676
let expected = multiple_extern_enums_query::ResponseData {
7777
distance: 100,

graphql_client/tests/interfaces.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ pub struct InterfaceQuery;
1414
fn interface_deserialization() {
1515
use interface_query::*;
1616

17-
println!("{:?}", RESPONSE);
17+
println!("{RESPONSE:?}");
1818
let response_data: interface_query::ResponseData = serde_json::from_str(RESPONSE).unwrap();
1919

20-
println!("{:?}", response_data);
20+
println!("{response_data:?}");
2121

2222
let expected = ResponseData {
2323
everything: Some(vec![

graphql_client/tests/json_schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn json_schemas_work_with_and_without_data_field() {
3333
serde_json::from_value(response).unwrap();
3434

3535
assert_eq!(
36-
format!("{:?}", schema_1_result),
36+
format!("{schema_1_result:?}"),
3737
format!("{:?}", schema_2_result)
3838
);
3939
}

graphql_client/tests/skip_serializing_none.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn skip_serializing_none() {
2727

2828
let stringified = serde_json::to_string(&query).expect("SkipSerializingNoneMutation is valid");
2929

30-
println!("{}", stringified);
30+
println!("{stringified}");
3131

3232
assert!(stringified.contains(r#""param":{"data":{"name":"test"}}"#));
3333
assert!(stringified.contains(r#""nonOptionalInt":1337"#));
@@ -48,7 +48,7 @@ fn skip_serializing_none() {
4848
}),
4949
});
5050
let stringified = serde_json::to_string(&query).expect("SkipSerializingNoneMutation is valid");
51-
println!("{}", stringified);
51+
println!("{stringified}");
5252
assert!(stringified.contains(r#""param":{"data":{"name":"test"}}"#));
5353
assert!(stringified.contains(r#""nonOptionalInt":1337"#));
5454
assert!(stringified.contains(r#""nonOptionalList":[]"#));

graphql_client_cli/src/generate.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ pub(crate) fn generate_code(params: CliCodegenParams) -> CliResult<()> {
7878
}
7979

8080
let gen = generate_module_token_stream(query_path.clone(), &schema_path, options)
81-
.map_err(|err| Error::message(format!("Error generating module code: {}", err)))?;
81+
.map_err(|err| Error::message(format!("Error generating module code: {err}")))?;
8282

83-
let generated_code = format!("{}\n{}", WARNING_SUPPRESSION, gen);
83+
let generated_code = format!("{WARNING_SUPPRESSION}\n{gen}");
8484
let generated_code = if !no_formatting {
8585
format(&generated_code)?
8686
} else {
@@ -107,7 +107,7 @@ pub(crate) fn generate_code(params: CliCodegenParams) -> CliResult<()> {
107107
format!("Creating file at {}", dest_file_path.display()),
108108
)
109109
})?;
110-
write!(file, "{}", generated_code)?;
110+
write!(file, "{generated_code}")?;
111111

112112
Ok(())
113113
}
@@ -121,7 +121,7 @@ fn format(code: &str) -> CliResult<String> {
121121
.spawn()
122122
.map_err(|err| Error::source_with_message(err, "Error spawning rustfmt".to_owned()))?;
123123
let child_stdin = child.stdin.as_mut().unwrap();
124-
write!(child_stdin, "{}", code)?;
124+
write!(child_stdin, "{code}")?;
125125

126126
let output = child.wait_with_output()?;
127127

graphql_client_cli/src/introspection_schema.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ pub fn introspect_schema(
8080
let error_message = match res.text() {
8181
Ok(msg) => match serde_json::from_str::<serde_json::Value>(&msg) {
8282
Ok(json) => format!("HTTP {}\n{}", status, serde_json::to_string_pretty(&json)?),
83-
Err(_) => format!("HTTP {}: {}", status, msg),
83+
Err(_) => format!("HTTP {status}: {msg}"),
8484
},
85-
Err(_) => format!("HTTP {}", status),
85+
Err(_) => format!("HTTP {status}"),
8686
};
8787
return Err(Error::message(error_message));
8888
}
@@ -113,8 +113,7 @@ impl FromStr for Header {
113113
// error: colon required for name/value pair
114114
if !input.contains(':') {
115115
return Err(format!(
116-
"Invalid header input. A colon is required to separate the name and value. [{}]",
117-
input
116+
"Invalid header input. A colon is required to separate the name and value. [{input}]"
118117
));
119118
}
120119

@@ -126,16 +125,14 @@ impl FromStr for Header {
126125
// error: field name must be
127126
if name.is_empty() {
128127
return Err(format!(
129-
"Invalid header input. Field name is required before colon. [{}]",
130-
input
128+
"Invalid header input. Field name is required before colon. [{input}]"
131129
));
132130
}
133131

134132
// error: no whitespace in field name
135133
if name.split_whitespace().count() > 1 {
136134
return Err(format!(
137-
"Invalid header input. Whitespace not allowed in field name. [{}]",
138-
input
135+
"Invalid header input. Whitespace not allowed in field name. [{input}]"
139136
));
140137
}
141138

@@ -196,12 +193,7 @@ mod tests {
196193
let header = Header::from_str(input);
197194

198195
assert!(header.is_ok(), "Expected ok: [{}]", input);
199-
assert_eq!(
200-
header.unwrap(),
201-
**expected,
202-
"Expected equality: [{}]",
203-
input
204-
);
196+
assert_eq!(header.unwrap(), **expected, "Expected equality: [{input}]");
205197
}
206198
}
207199
}

graphql_client_codegen/src/codegen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fn generate_scalar_definitions<'a, 'schema: 'a>(
181181
fn render_derives<'a>(derives: impl Iterator<Item = &'a str>) -> impl quote::ToTokens {
182182
let idents = derives.map(|s| {
183183
syn::parse_str::<syn::Path>(s)
184-
.map_err(|e| format!("couldn't parse {} as a derive Path: {}", s, e))
184+
.map_err(|e| format!("couldn't parse {s} as a derive Path: {e}"))
185185
.unwrap()
186186
});
187187

0 commit comments

Comments
 (0)