Skip to content

Commit 4e08828

Browse files
committed
Fix clippy warnings
1 parent f292ca3 commit 4e08828

File tree

10 files changed

+24
-22
lines changed

10 files changed

+24
-22
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## Unreleased
99

10-
This release sees the switch to the Rust 2018 edition and is only compatible with Rust 1.31.0 and later.
10+
This release sees the switch to the Rust 2018 edition - it is
11+
only compatible with Rust 1.31.0 and later.
1112

1213
## 0.7.1
1314

graphql_client/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
//!
33
//! The main interface to this library is the custom derive that generates modules from a GraphQL query and schema. See the docs for the [`GraphQLQuery`] trait for a full example.
44
5-
#![deny(warnings)]
65
#![deny(missing_docs)]
76
#![deny(rust_2018_idioms)]
7+
#![deny(warnings)]
88

99
#[allow(unused_imports)]
1010
#[macro_use]

graphql_client_cli/src/generate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub(crate) fn generate_code(params: CliCodegenParams) -> Result<(), failure::Err
6464

6565
let query_file_name: ::std::ffi::OsString = query_path
6666
.file_name()
67-
.map(|s| s.to_owned())
67+
.map(ToOwned::to_owned)
6868
.ok_or_else(|| format_err!("Failed to find a file name in the provided query path."))?;
6969

7070
let dest_file_path: PathBuf = output_directory

graphql_client_cli/src/introspect_schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl FromStr for Header {
7777

7878
fn from_str(input: &str) -> Result<Self, Self::Err> {
7979
// error: colon required for name/value pair
80-
if !input.contains(":") {
80+
if !input.contains(':') {
8181
return Err(format_err!(
8282
"Invalid header input. A colon is required to separate the name and value. [{}]",
8383
input
@@ -90,7 +90,7 @@ impl FromStr for Header {
9090
let value = name_value[1].trim();
9191

9292
// error: field name must be
93-
if name.len() == 0 {
93+
if name.is_empty() {
9494
return Err(format_err!(
9595
"Invalid header input. Field name is required before colon. [{}]",
9696
input

graphql_client_codegen/src/codegen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub(crate) fn select_operation<'query>(
1818
operations
1919
.iter()
2020
.find(|op| op.name == struct_name)
21-
.map(|i| i.to_owned())
21+
.map(ToOwned::to_owned)
2222
}
2323

2424
pub(crate) fn all_operations(query: &query::Document) -> Vec<Operation<'_>> {

graphql_client_codegen/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![recursion_limit = "512"]
22
#![deny(missing_docs)]
3+
#![deny(rust_2018_idioms)]
34
#![deny(warnings)]
45

56
//! Crate for internal use by other graphql-client crates, for code generation.
@@ -167,7 +168,7 @@ fn derive_operation_not_found_error(
167168
) -> failure::Error {
168169
use graphql_parser::query::*;
169170

170-
let operation_name = ident.map(|i| i.to_string());
171+
let operation_name = ident.map(ToString::to_string);
171172
let struct_ident = operation_name.as_ref().map(String::as_str).unwrap_or("");
172173

173174
let available_operations = query

graphql_client_codegen/src/objects.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<'schema> GqlObject<'schema> {
6868
}
6969

7070
pub fn from_graphql_parser_object(obj: &'schema schema::ObjectType) -> Self {
71-
let description = obj.description.as_ref().map(|s| s.as_str());
71+
let description = obj.description.as_ref().map(String::as_str);
7272
let mut item = GqlObject::new(&obj.name, description);
7373
item.fields.extend(obj.fields.iter().map(|f| {
7474
let deprecation = parse_deprecation_info(&f);

graphql_client_codegen/src/query.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ impl<'query, 'schema> QueryContext<'query, 'schema> {
9191
self.variables_derives.extend(
9292
attribute_value
9393
.split(',')
94-
.map(|s| s.trim())
94+
.map(str::trim)
9595
.map(|s| Ident::new(s, Span::call_site())),
9696
);
9797
self.response_derives.extend(
9898
attribute_value
9999
.split(',')
100-
.map(|s| s.trim())
100+
.map(str::trim)
101101
.map(|s| Ident::new(s, Span::call_site())),
102102
);
103103
Ok(())

graphql_client_codegen/src/schema.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl<'schema> ::std::convert::From<&'schema graphql_parser::schema::Document> fo
159159
}
160160
schema::TypeDefinition::Union(union) => {
161161
let variants: BTreeSet<&str> =
162-
union.types.iter().map(|s| s.as_str()).collect();
162+
union.types.iter().map(String::as_str).collect();
163163
schema.unions.insert(
164164
&union.name,
165165
GqlUnion {
@@ -173,12 +173,12 @@ impl<'schema> ::std::convert::From<&'schema graphql_parser::schema::Document> fo
173173
schema::TypeDefinition::Interface(interface) => {
174174
let mut iface = GqlInterface::new(
175175
&interface.name,
176-
interface.description.as_ref().map(|d| d.as_str()),
176+
interface.description.as_ref().map(String::as_str),
177177
);
178178
iface
179179
.fields
180180
.extend(interface.fields.iter().map(|f| GqlObjectField {
181-
description: f.description.as_ref().map(|s| s.as_str()),
181+
description: f.description.as_ref().map(String::as_str),
182182
name: f.name.as_str(),
183183
type_: FieldType::from(&f.field_type),
184184
deprecation: DeprecationStatus::Current,
@@ -192,9 +192,9 @@ impl<'schema> ::std::convert::From<&'schema graphql_parser::schema::Document> fo
192192
schema::Definition::DirectiveDefinition(_) => (),
193193
schema::Definition::TypeExtension(_extension) => (),
194194
schema::Definition::SchemaDefinition(definition) => {
195-
schema.query_type = definition.query.as_ref().map(|s| s.as_str());
196-
schema.mutation_type = definition.mutation.as_ref().map(|s| s.as_str());
197-
schema.subscription_type = definition.subscription.as_ref().map(|s| s.as_str());
195+
schema.query_type = definition.query.as_ref().map(String::as_str);
196+
schema.mutation_type = definition.mutation.as_ref().map(String::as_str);
197+
schema.subscription_type = definition.subscription.as_ref().map(String::as_str);
198198
}
199199
}
200200
}
@@ -224,17 +224,17 @@ impl<'schema> ::std::convert::From<&'schema crate::introspection_response::Intro
224224
.query_type
225225
.as_ref()
226226
.and_then(|ty| ty.name.as_ref())
227-
.map(|s| s.as_str());
227+
.map(String::as_str);
228228
schema.mutation_type = root
229229
.mutation_type
230230
.as_ref()
231231
.and_then(|ty| ty.name.as_ref())
232-
.map(|s| s.as_str());
232+
.map(String::as_str);
233233
schema.subscription_type = root
234234
.subscription_type
235235
.as_ref()
236236
.and_then(|ty| ty.name.as_ref())
237-
.map(|s| s.as_str());
237+
.map(String::as_str);
238238

239239
// Holds which objects implement which interfaces so we can populate GqlInterface#implemented_by later.
240240
// It maps interface names to a vec of implementation names.
@@ -320,7 +320,7 @@ impl<'schema> ::std::convert::From<&'schema crate::introspection_response::Intro
320320
.map(Vec::as_slice)
321321
.unwrap_or_else(|| &[])
322322
.iter()
323-
.filter_map(|t| t.as_ref())
323+
.filter_map(Option::as_ref)
324324
.map(|t| &t.type_ref.name)
325325
{
326326
interface_implementations
@@ -340,7 +340,7 @@ impl<'schema> ::std::convert::From<&'schema crate::introspection_response::Intro
340340
}
341341
Some(__TypeKind::INTERFACE) => {
342342
let mut iface =
343-
GqlInterface::new(name, ty.description.as_ref().map(|t| t.as_str()));
343+
GqlInterface::new(name, ty.description.as_ref().map(String::as_str));
344344
iface.fields.extend(
345345
ty.fields
346346
.as_ref()

graphql_query_derive/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn graphql_query_derive_inner(
3636
let options = build_graphql_client_derive_options(&ast, query_path.to_path_buf())?;
3737
Ok(
3838
generate_module_token_stream(query_path, &schema_path, options)
39-
.map(|module| module.into())
39+
.map(Into::into)
4040
.context("Code generation failed.")?,
4141
)
4242
}

0 commit comments

Comments
 (0)