Skip to content

Commit 21de4a8

Browse files
committed
run cargo clippy
This commit updates code according to clippy recommendations
1 parent 9e7468a commit 21de4a8

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

api_generator/src/api_generator/code_gen/params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn generate_param(tokens: &mut Tokens, e: &ApiEnum) {
2424
.iter()
2525
.filter(|v| !v.is_empty())
2626
.map(|v| {
27-
if !v.contains("(") {
27+
if !v.contains('(') {
2828
(v.to_owned(), syn::Ident::from(v.to_pascal_case()))
2929
} else {
3030
lazy_static! {

api_generator/src/api_generator/code_gen/request/request_builder.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,13 @@ impl<'a> RequestBuilder<'a> {
368368
accepts_nd_body: bool,
369369
) -> Tokens {
370370
// TODO: lazy_static! for this?
371-
let common_fields: Vec<Field> = common_params
371+
let mut common_fields: Vec<Field> = common_params
372372
.iter()
373373
.map(Self::create_struct_field)
374374
.collect();
375375

376376
// TODO: lazy_static! for this?
377-
let common_builder_fns: Vec<ImplItem> =
377+
let mut common_builder_fns: Vec<ImplItem> =
378378
common_params.iter().map(Self::create_impl_fn).collect();
379379

380380
let supports_body = endpoint.supports_body();
@@ -408,8 +408,7 @@ impl<'a> RequestBuilder<'a> {
408408
}
409409

410410
// Combine common fields with struct fields, sort and deduplicate
411-
// clone common_fields, since quote!() consumes the Vec<Field>
412-
fields.append(&mut common_fields.to_vec().clone());
411+
fields.append(&mut common_fields);
413412
fields.sort_by(|a, b| a.ident.cmp(&b.ident));
414413
fields.dedup_by(|a, b| a.ident.eq(&b.ident));
415414

@@ -438,8 +437,7 @@ impl<'a> RequestBuilder<'a> {
438437
}
439438

440439
// Combine common fns with builder fns, sort and deduplicate.
441-
// clone is required, since quote!() consumes the Vec<Item>
442-
builder_fns.append(&mut common_builder_fns.to_vec().clone());
440+
builder_fns.append(&mut common_builder_fns);
443441
builder_fns.sort_by(|a, b| a.ident.cmp(&b.ident));
444442
builder_fns.dedup_by(|a, b| a.ident.eq(&b.ident));
445443

api_generator/src/api_generator/code_gen/url/url_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl<'a> UrlBuilder<'a> {
340340
syn::Stmt::Local(Box::new(syn::Local {
341341
pat: Box::new(syn::Pat::Ident(
342342
syn::BindingMode::ByValue(syn::Mutability::Mutable),
343-
url_ident.to_owned(),
343+
url_ident,
344344
None,
345345
)),
346346
ty: None,

api_generator/src/api_generator/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ pub fn generate(
291291
write_file(root, generated_dir, "root.rs")?;
292292

293293
let generated_modules = fs::read_dir(generated_dir)?
294-
.into_iter()
295294
.map(|r| {
296295
let path = r.unwrap().path();
297296
format!("pub mod {};", path.file_stem().unwrap().to_string_lossy())
@@ -334,7 +333,7 @@ fn write_file(input: String, dir: &PathBuf, file: &str) -> Result<(), failure::E
334333

335334
let mut file = OpenOptions::new().append(true).write(true).open(&path)?;
336335
file.write_all(input.as_bytes())?;
337-
file.write(b"\n")?;
336+
file.write_all(b"\n")?;
338337

339338
Ok(())
340339
}

0 commit comments

Comments
 (0)