Skip to content

Commit d73b780

Browse files
author
daniel.eades
committed
use 'Self' keyword (clippy::use_self)
1 parent d7e96ff commit d73b780

File tree

12 files changed

+121
-121
lines changed

12 files changed

+121
-121
lines changed

graphql-introspection-query/src/introspection_response.rs

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,25 @@ pub enum __DirectiveLocation {
2828
impl Serialize for __DirectiveLocation {
2929
fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
3030
ser.serialize_str(match *self {
31-
__DirectiveLocation::QUERY => "QUERY",
32-
__DirectiveLocation::MUTATION => "MUTATION",
33-
__DirectiveLocation::SUBSCRIPTION => "SUBSCRIPTION",
34-
__DirectiveLocation::FIELD => "FIELD",
35-
__DirectiveLocation::FRAGMENT_DEFINITION => "FRAGMENT_DEFINITION",
36-
__DirectiveLocation::FRAGMENT_SPREAD => "FRAGMENT_SPREAD",
37-
__DirectiveLocation::INLINE_FRAGMENT => "INLINE_FRAGMENT",
38-
__DirectiveLocation::SCHEMA => "SCHEMA",
39-
__DirectiveLocation::SCALAR => "SCALAR",
40-
__DirectiveLocation::OBJECT => "OBJECT",
41-
__DirectiveLocation::FIELD_DEFINITION => "FIELD_DEFINITION",
42-
__DirectiveLocation::ARGUMENT_DEFINITION => "ARGUMENT_DEFINITION",
43-
__DirectiveLocation::INTERFACE => "INTERFACE",
44-
__DirectiveLocation::UNION => "UNION",
45-
__DirectiveLocation::ENUM => "ENUM",
46-
__DirectiveLocation::ENUM_VALUE => "ENUM_VALUE",
47-
__DirectiveLocation::INPUT_OBJECT => "INPUT_OBJECT",
48-
__DirectiveLocation::INPUT_FIELD_DEFINITION => "INPUT_FIELD_DEFINITION",
49-
__DirectiveLocation::Other(ref s) => s.as_str(),
31+
Self::QUERY => "QUERY",
32+
Self::MUTATION => "MUTATION",
33+
Self::SUBSCRIPTION => "SUBSCRIPTION",
34+
Self::FIELD => "FIELD",
35+
Self::FRAGMENT_DEFINITION => "FRAGMENT_DEFINITION",
36+
Self::FRAGMENT_SPREAD => "FRAGMENT_SPREAD",
37+
Self::INLINE_FRAGMENT => "INLINE_FRAGMENT",
38+
Self::SCHEMA => "SCHEMA",
39+
Self::SCALAR => "SCALAR",
40+
Self::OBJECT => "OBJECT",
41+
Self::FIELD_DEFINITION => "FIELD_DEFINITION",
42+
Self::ARGUMENT_DEFINITION => "ARGUMENT_DEFINITION",
43+
Self::INTERFACE => "INTERFACE",
44+
Self::UNION => "UNION",
45+
Self::ENUM => "ENUM",
46+
Self::ENUM_VALUE => "ENUM_VALUE",
47+
Self::INPUT_OBJECT => "INPUT_OBJECT",
48+
Self::INPUT_FIELD_DEFINITION => "INPUT_FIELD_DEFINITION",
49+
Self::Other(ref s) => s.as_str(),
5050
})
5151
}
5252
}
@@ -55,25 +55,25 @@ impl<'de> Deserialize<'de> for __DirectiveLocation {
5555
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5656
let s = <&'de str>::deserialize(deserializer)?;
5757
match s {
58-
"QUERY" => Ok(__DirectiveLocation::QUERY),
59-
"MUTATION" => Ok(__DirectiveLocation::MUTATION),
60-
"SUBSCRIPTION" => Ok(__DirectiveLocation::SUBSCRIPTION),
61-
"FIELD" => Ok(__DirectiveLocation::FIELD),
62-
"FRAGMENT_DEFINITION" => Ok(__DirectiveLocation::FRAGMENT_DEFINITION),
63-
"FRAGMENT_SPREAD" => Ok(__DirectiveLocation::FRAGMENT_SPREAD),
64-
"INLINE_FRAGMENT" => Ok(__DirectiveLocation::INLINE_FRAGMENT),
65-
"SCHEMA" => Ok(__DirectiveLocation::SCHEMA),
66-
"SCALAR" => Ok(__DirectiveLocation::SCALAR),
67-
"OBJECT" => Ok(__DirectiveLocation::OBJECT),
68-
"FIELD_DEFINITION" => Ok(__DirectiveLocation::FIELD_DEFINITION),
69-
"ARGUMENT_DEFINITION" => Ok(__DirectiveLocation::ARGUMENT_DEFINITION),
70-
"INTERFACE" => Ok(__DirectiveLocation::INTERFACE),
71-
"UNION" => Ok(__DirectiveLocation::UNION),
72-
"ENUM" => Ok(__DirectiveLocation::ENUM),
73-
"ENUM_VALUE" => Ok(__DirectiveLocation::ENUM_VALUE),
74-
"INPUT_OBJECT" => Ok(__DirectiveLocation::INPUT_OBJECT),
75-
"INPUT_FIELD_DEFINITION" => Ok(__DirectiveLocation::INPUT_FIELD_DEFINITION),
76-
_ => Ok(__DirectiveLocation::Other(s.to_string())),
58+
"QUERY" => Ok(Self::QUERY),
59+
"MUTATION" => Ok(Self::MUTATION),
60+
"SUBSCRIPTION" => Ok(Self::SUBSCRIPTION),
61+
"FIELD" => Ok(Self::FIELD),
62+
"FRAGMENT_DEFINITION" => Ok(Self::FRAGMENT_DEFINITION),
63+
"FRAGMENT_SPREAD" => Ok(Self::FRAGMENT_SPREAD),
64+
"INLINE_FRAGMENT" => Ok(Self::INLINE_FRAGMENT),
65+
"SCHEMA" => Ok(Self::SCHEMA),
66+
"SCALAR" => Ok(Self::SCALAR),
67+
"OBJECT" => Ok(Self::OBJECT),
68+
"FIELD_DEFINITION" => Ok(Self::FIELD_DEFINITION),
69+
"ARGUMENT_DEFINITION" => Ok(Self::ARGUMENT_DEFINITION),
70+
"INTERFACE" => Ok(Self::INTERFACE),
71+
"UNION" => Ok(Self::UNION),
72+
"ENUM" => Ok(Self::ENUM),
73+
"ENUM_VALUE" => Ok(Self::ENUM_VALUE),
74+
"INPUT_OBJECT" => Ok(Self::INPUT_OBJECT),
75+
"INPUT_FIELD_DEFINITION" => Ok(Self::INPUT_FIELD_DEFINITION),
76+
_ => Ok(Self::Other(s.to_string())),
7777
}
7878
}
7979
}
@@ -94,15 +94,15 @@ pub enum __TypeKind {
9494
impl Serialize for __TypeKind {
9595
fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
9696
ser.serialize_str(match *self {
97-
__TypeKind::SCALAR => "SCALAR",
98-
__TypeKind::OBJECT => "OBJECT",
99-
__TypeKind::INTERFACE => "INTERFACE",
100-
__TypeKind::UNION => "UNION",
101-
__TypeKind::ENUM => "ENUM",
102-
__TypeKind::INPUT_OBJECT => "INPUT_OBJECT",
103-
__TypeKind::LIST => "LIST",
104-
__TypeKind::NON_NULL => "NON_NULL",
105-
__TypeKind::Other(ref s) => s.as_str(),
97+
Self::SCALAR => "SCALAR",
98+
Self::OBJECT => "OBJECT",
99+
Self::INTERFACE => "INTERFACE",
100+
Self::UNION => "UNION",
101+
Self::ENUM => "ENUM",
102+
Self::INPUT_OBJECT => "INPUT_OBJECT",
103+
Self::LIST => "LIST",
104+
Self::NON_NULL => "NON_NULL",
105+
Self::Other(ref s) => s.as_str(),
106106
})
107107
}
108108
}
@@ -111,15 +111,15 @@ impl<'de> Deserialize<'de> for __TypeKind {
111111
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
112112
let s = <&'de str>::deserialize(deserializer)?;
113113
match s {
114-
"SCALAR" => Ok(__TypeKind::SCALAR),
115-
"OBJECT" => Ok(__TypeKind::OBJECT),
116-
"INTERFACE" => Ok(__TypeKind::INTERFACE),
117-
"UNION" => Ok(__TypeKind::UNION),
118-
"ENUM" => Ok(__TypeKind::ENUM),
119-
"INPUT_OBJECT" => Ok(__TypeKind::INPUT_OBJECT),
120-
"LIST" => Ok(__TypeKind::LIST),
121-
"NON_NULL" => Ok(__TypeKind::NON_NULL),
122-
_ => Ok(__TypeKind::Other(s.to_string())),
114+
"SCALAR" => Ok(Self::SCALAR),
115+
"OBJECT" => Ok(Self::OBJECT),
116+
"INTERFACE" => Ok(Self::INTERFACE),
117+
"UNION" => Ok(Self::UNION),
118+
"ENUM" => Ok(Self::ENUM),
119+
"INPUT_OBJECT" => Ok(Self::INPUT_OBJECT),
120+
"LIST" => Ok(Self::LIST),
121+
"NON_NULL" => Ok(Self::NON_NULL),
122+
_ => Ok(Self::Other(s.to_string())),
123123
}
124124
}
125125
}
@@ -288,15 +288,15 @@ pub enum IntrospectionResponse {
288288
impl IntrospectionResponse {
289289
pub fn as_schema(&self) -> &SchemaContainer {
290290
match self {
291-
IntrospectionResponse::FullResponse(full_response) => &full_response.data,
292-
IntrospectionResponse::Schema(schema) => schema,
291+
Self::FullResponse(full_response) => &full_response.data,
292+
Self::Schema(schema) => schema,
293293
}
294294
}
295295

296296
pub fn into_schema(self) -> SchemaContainer {
297297
match self {
298-
IntrospectionResponse::FullResponse(full_response) => full_response.data,
299-
IntrospectionResponse::Schema(schema) => schema,
298+
Self::FullResponse(full_response) => full_response.data,
299+
Self::Schema(schema) => schema,
300300
}
301301
}
302302
}

graphql_client/src/lib.rs

Lines changed: 2 additions & 2 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+
Self::Key(ref key) => write!(f, "{key}"),
126+
Self::Index(ref idx) => write!(f, "{idx}"),
127127
}
128128
}
129129
}

graphql_client_cli/src/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub struct Error {
99
impl Error {
1010
#[track_caller]
1111
pub fn message(msg: String) -> Self {
12-
Error {
12+
Self {
1313
source: None,
1414
message: Some(msg),
1515
location: std::panic::Location::caller(),
@@ -21,7 +21,7 @@ impl Error {
2121
source: impl std::error::Error + Send + Sync + 'static,
2222
message: String,
2323
) -> Self {
24-
let mut err = Error::message(message);
24+
let mut err = Self::message(message);
2525
err.source = Some(Box::new(source));
2626
err
2727
}
@@ -56,7 +56,7 @@ where
5656
{
5757
#[track_caller]
5858
fn from(err: T) -> Self {
59-
Error {
59+
Self {
6060
message: None,
6161
source: Some(Box::new(err)),
6262
location: std::panic::Location::caller(),

graphql_client_codegen/src/codegen/selection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<'a> VariantSelection<'a> {
9191
selection: &'a Selection,
9292
type_id: TypeId,
9393
query: &BoundQuery<'a>,
94-
) -> Option<VariantSelection<'a>> {
94+
) -> Option<Self> {
9595
match selection {
9696
Selection::InlineFragment(inline_fragment) => {
9797
Some(VariantSelection::InlineFragment(inline_fragment))

graphql_client_codegen/src/codegen_options.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ pub struct GraphQLClientCodegenOptions {
5353

5454
impl GraphQLClientCodegenOptions {
5555
/// Creates an empty options object with default params. It probably wants to be configured.
56-
pub fn new(mode: CodegenMode) -> GraphQLClientCodegenOptions {
57-
GraphQLClientCodegenOptions {
56+
pub fn new(mode: CodegenMode) -> Self {
57+
Self {
5858
mode,
5959
variables_derives: Default::default(),
6060
response_derives: Default::default(),

graphql_client_codegen/src/deprecation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ impl std::str::FromStr for DeprecationStrategy {
2424

2525
fn from_str(s: &str) -> Result<Self, ()> {
2626
match s.trim() {
27-
"allow" => Ok(DeprecationStrategy::Allow),
28-
"deny" => Ok(DeprecationStrategy::Deny),
29-
"warn" => Ok(DeprecationStrategy::Warn),
27+
"allow" => Ok(Self::Allow),
28+
"deny" => Ok(Self::Deny),
29+
"warn" => Ok(Self::Warn),
3030
_ => Err(()),
3131
}
3232
}

graphql_client_codegen/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ enum ReadFileError {
178178
impl Display for ReadFileError {
179179
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
180180
match self {
181-
ReadFileError::FileNotFound { path, .. } => {
181+
Self::FileNotFound { path, .. } => {
182182
write!(f, "Could not find file with path: {path}\n
183183
Hint: file paths in the GraphQLQuery attribute are relative to the project root (location of the Cargo.toml). Example: query_path = \"src/my_query.graphql\".")
184184
}
185-
ReadFileError::ReadError { path, .. } => {
185+
Self::ReadError { path, .. } => {
186186
f.write_str("Error reading file at: ")?;
187187
f.write_str(path)
188188
}
@@ -193,8 +193,9 @@ impl Display for ReadFileError {
193193
impl std::error::Error for ReadFileError {
194194
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
195195
match self {
196-
ReadFileError::FileNotFound { io_error, .. }
197-
| ReadFileError::ReadError { io_error, .. } => Some(io_error),
196+
Self::FileNotFound { io_error, .. } | Self::ReadError { io_error, .. } => {
197+
Some(io_error)
198+
}
198199
}
199200
}
200201
}

graphql_client_codegen/src/normalization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ impl std::str::FromStr for Normalization {
5656

5757
fn from_str(s: &str) -> Result<Self, ()> {
5858
match s.trim() {
59-
"none" => Ok(Normalization::None),
60-
"rust" => Ok(Normalization::Rust),
59+
"none" => Ok(Self::None),
60+
"rust" => Ok(Self::Rust),
6161
_ => Err(()),
6262
}
6363
}

graphql_client_codegen/src/query.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl std::error::Error for QueryValidationError {}
3838

3939
impl QueryValidationError {
4040
pub(crate) fn new(message: String) -> Self {
41-
QueryValidationError { message }
41+
Self { message }
4242
}
4343
}
4444

@@ -49,7 +49,7 @@ pub(crate) struct OperationId(u32);
4949

5050
impl OperationId {
5151
pub(crate) fn new(idx: usize) -> Self {
52-
OperationId(idx as u32)
52+
Self(idx as u32)
5353
}
5454
}
5555

0 commit comments

Comments
 (0)