Skip to content

Commit e81b892

Browse files
committed
to be squashed: use itertools for formatting
1 parent e1e6e38 commit e81b892

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

graphql_client_codegen/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ repository = "https://github.com/graphql-rust/graphql-client"
88

99
[dependencies]
1010
failure = "0.1"
11+
itertools = "0.8"
1112
lazy_static = "1.0"
1213
quote = "0.6"
1314
syn = "0.15.20"

graphql_client_codegen/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
extern crate failure;
1010
extern crate graphql_parser;
1111
extern crate heck;
12+
extern crate itertools;
1213
#[macro_use]
1314
extern crate lazy_static;
1415
extern crate proc_macro;

graphql_client_codegen/src/shared.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,10 @@ use objects::GqlObjectField;
55
use proc_macro2::{Ident, Span, TokenStream};
66
use query::QueryContext;
77
use selection::*;
8+
use itertools::Itertools;
89

910
fn format_available_fields(fields: &[GqlObjectField]) -> String {
10-
fields
11-
.iter()
12-
.map(|ref field| &field.name)
13-
.fold(String::new(), |mut acc, item| {
14-
acc.push_str(item);
15-
acc.push_str(", ");
16-
acc
17-
})
18-
.trim_end_matches(", ")
19-
.to_owned()
11+
fields.iter().map(|ref field| &field.name).format("`, `").to_string()
2012
}
2113

2214
pub(crate) fn render_object_field(

0 commit comments

Comments
 (0)