Skip to content

Commit dccd1b6

Browse files
author
Vincent Prouillet
committed
More clippy changes
1 parent d21d5b7 commit dccd1b6

File tree

2 files changed

+50
-23
lines changed

2 files changed

+50
-23
lines changed

src/query_grammar.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,16 @@ pub fn query<'a>(input: &mut TokenStream<'a>)
274274
.parse_stream(input)
275275
}
276276

277+
/// A set of attributes common to a Query and a Mutation
278+
type OperationCommon = (
279+
Option<String>,
280+
Vec<VariableDefinition>,
281+
Vec<Directive>,
282+
SelectionSet,
283+
);
284+
277285
pub fn operation_common<'a>(input: &mut TokenStream<'a>)
278-
-> ParseResult<
279-
(Option<String>, Vec<VariableDefinition>, Vec<Directive>,
280-
SelectionSet),
281-
TokenStream<'a>>
286+
-> ParseResult<OperationCommon, TokenStream<'a>>
282287
{
283288
optional(name())
284289
.and(optional(

src/tokenizer.rs

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,22 @@ impl<'a> TokenStream<'a> {
142142
'(' | ')' | '[' | ']' | '{' | '}' => {
143143
self.position.column += 1;
144144
self.off += 1;
145-
return Ok((Punctuator, 1));
145+
146+
Ok((Punctuator, 1))
146147
}
147148
'.' => {
148149
if iter.as_str().starts_with("..") {
149150
self.position.column += 3;
150151
self.off += 3;
151-
return Ok((Punctuator, 3))
152+
153+
Ok((Punctuator, 3))
152154
} else {
153-
return Err(Error::unexpected_message(
155+
Err(
156+
Error::unexpected_message(
154157
format_args!("bare dot {:?} is not supported, \
155-
only \"...\"", cur_char)));
158+
only \"...\"", cur_char)
159+
)
160+
)
156161
}
157162
}
158163
'_' | 'a'...'z' | 'A'...'Z' => {
@@ -169,7 +174,8 @@ impl<'a> TokenStream<'a> {
169174
let len = self.buf.len() - self.off;
170175
self.position.column += len;
171176
self.off += len;
172-
return Ok((Name, len));
177+
178+
Ok((Name, len))
173179
}
174180
'-' | '0'...'9' => {
175181
let mut exponent = None;
@@ -190,6 +196,7 @@ impl<'a> TokenStream<'a> {
190196
_ => {},
191197
}
192198
};
199+
193200
if exponent.is_some() || real.is_some() {
194201
let value = &self.buf[self.off..][..len];
195202
if !check_float(value, exponent, real) {
@@ -198,7 +205,8 @@ impl<'a> TokenStream<'a> {
198205
}
199206
self.position.column += len;
200207
self.off += len;
201-
return Ok((FloatValue, len));
208+
209+
Ok((FloatValue, len))
202210
} else {
203211
let value = &self.buf[self.off..][..len];
204212
if !check_int(value) {
@@ -207,20 +215,25 @@ impl<'a> TokenStream<'a> {
207215
}
208216
self.position.column += len;
209217
self.off += len;
210-
return Ok((IntValue, len));
218+
219+
Ok((IntValue, len))
211220
}
212221
}
213222
'"' => {
214223
if iter.as_str().starts_with("\"\"") {
215224
let tail = &iter.as_str()[2..];
216-
for (endidx, _) in tail.match_indices("\"\"\"") {
217-
if !tail[..endidx].ends_with('\\') {
218-
self.update_position(endidx+6);
219-
return Ok((BlockString, endidx+6));
225+
for (end_idx, _) in tail.match_indices("\"\"\"") {
226+
if !tail[..end_idx].ends_with('\\') {
227+
self.update_position(end_idx + 6);
228+
return Ok((BlockString, end_idx + 6));
220229
}
221230
}
222-
return Err(Error::unexpected_message(
223-
"unterminated block string value"));
231+
232+
Err(
233+
Error::unexpected_message(
234+
"unterminated block string value"
235+
)
236+
)
224237
} else {
225238
let mut prev_char = cur_char;
226239
let mut nchars = 1;
@@ -234,21 +247,30 @@ impl<'a> TokenStream<'a> {
234247
return Ok((StringValue, idx+1));
235248
}
236249
'\n' => {
237-
return Err(Error::unexpected_message(
238-
"unterminated string value"));
250+
return Err(
251+
Error::unexpected_message(
252+
"unterminated string value"
253+
)
254+
);
239255
}
240256
_ => {
241257

242258
}
243259
}
244260
prev_char = cur_char;
245261
}
246-
return Err(Error::unexpected_message(
247-
"unterminated string value"));
262+
Err(
263+
Error::unexpected_message(
264+
"unterminated string value"
265+
)
266+
)
248267
}
249268
}
250-
_ => return Err(Error::unexpected_message(
251-
format_args!("unexpected character {:?}", cur_char))),
269+
_ => Err(
270+
Error::unexpected_message(
271+
format_args!("unexpected character {:?}", cur_char)
272+
)
273+
),
252274
}
253275
}
254276

0 commit comments

Comments
 (0)