Skip to content

Commit a0af426

Browse files
committed
Satisfy rustfmt
1 parent b8b0490 commit a0af426

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

graphql_client_cli/src/introspect_schema.rs

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ pub fn introspect_schema(
3939
let mut req_builder = client.post(location).headers(construct_headers());
4040

4141
for custom_header in headers {
42-
req_builder = req_builder.header(
43-
custom_header.name.as_str(),
44-
custom_header.value.as_str(),
45-
);
42+
req_builder = req_builder.header(custom_header.name.as_str(), custom_header.value.as_str());
4643
}
4744

4845
if let Some(token) = authorization {
@@ -79,11 +76,14 @@ pub struct Header {
7976

8077
impl FromStr for Header {
8178
type Err = failure::Error;
82-
79+
8380
fn from_str(input: &str) -> Result<Self, Self::Err> {
8481
// error: colon required for name/value pair
85-
if ! input.contains(":") {
86-
return Err(format_err!("Invalid header input. A colon is required to separate the name and value. [{}]", input));
82+
if !input.contains(":") {
83+
return Err(format_err!(
84+
"Invalid header input. A colon is required to separate the name and value. [{}]",
85+
input
86+
));
8787
}
8888

8989
// split on first colon and trim whitespace from name and value
@@ -93,15 +93,24 @@ impl FromStr for Header {
9393

9494
// error: field name must be
9595
if name.len() == 0 {
96-
return Err(format_err!("Invalid header input. Field name is required before colon. [{}]", input));
96+
return Err(format_err!(
97+
"Invalid header input. Field name is required before colon. [{}]",
98+
input
99+
));
97100
}
98-
101+
99102
// error: no whitespace in field name
100103
if name.split_whitespace().count() > 1 {
101-
return Err(format_err!("Invalid header input. Whitespace not allowed in field name. [{}]", input));
104+
return Err(format_err!(
105+
"Invalid header input. Whitespace not allowed in field name. [{}]",
106+
input
107+
));
102108
}
103109

104-
Ok(Self{name: name.to_string(), value: value.to_string()})
110+
Ok(Self {
111+
name: name.to_string(),
112+
value: value.to_string(),
113+
})
105114
}
106115
}
107116

@@ -129,8 +138,14 @@ mod tests {
129138
fn it_parses_valid_headers() {
130139
// https://tools.ietf.org/html/rfc7230#section-3.2
131140

132-
let expected1 = Header{name: "X-Name".to_string(), value: "Value".to_string()};
133-
let expected2 = Header{name: "X-Name".to_string(), value: "Value:".to_string()};
141+
let expected1 = Header {
142+
name: "X-Name".to_string(),
143+
value: "Value".to_string(),
144+
};
145+
let expected2 = Header {
146+
name: "X-Name".to_string(),
147+
value: "Value:".to_string(),
148+
};
134149

135150
for (input, expected) in vec![
136151
("X-Name: Value", &expected1), // ideal

graphql_client_cli/src/main.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,7 @@ fn main() -> Result<(), failure::Error> {
9090
output,
9191
authorization,
9292
headers,
93-
} => introspect_schema::introspect_schema(
94-
&schema_location,
95-
output,
96-
authorization,
97-
headers,
98-
),
93+
} => introspect_schema::introspect_schema(&schema_location, output, authorization, headers),
9994
Cli::Generate {
10095
additional_derives,
10196
deprecation_strategy,

0 commit comments

Comments
 (0)