Remove itertools dependency

This commit is contained in:
Koxiaet 2020-10-16 06:37:48 +01:00
parent ec3e1a9044
commit 1205d6e91e
6 changed files with 37 additions and 38 deletions

View File

@ -33,7 +33,6 @@ async-trait = "0.1.41"
fnv = "1.0.6"
futures = "0.3.6"
indexmap = "1.6.0"
itertools = "0.9.0"
once_cell = "1.3.1"
pin-project-lite = "0.1.10"
regex = "1.4.1"

View File

@ -22,6 +22,5 @@ syn = { version = "1.0.44", features = ["full", "extra-traits", "visit-mut"] }
quote = "1.0.3"
Inflector = "0.11.4"
proc-macro-crate = "0.1.4"
itertools = "0.9.0"
darling = "0.10"
thiserror = "1.0"

@ -1 +1 @@
Subproject commit f085046edb8933754ddc71c5da577d7b44bcf0bb
Subproject commit cb3360847366d2fd70a33eb5f9df60e90e8979da

View File

@ -1,7 +1,5 @@
use std::fmt::Write;
use itertools::Itertools;
use crate::registry::{MetaField, MetaInputValue, MetaType, Registry};
impl Registry {
@ -59,18 +57,14 @@ impl Registry {
.ok();
}
if !field.args.is_empty() {
write!(
sdl,
"\t{}({}): {}",
field.name,
field
.args
.values()
.map(|arg| export_input_value(arg))
.join(", "),
field.ty
)
.ok();
write!(sdl, "\t{}(", field.name).ok();
for (i, arg) in field.args.values().enumerate() {
if i != 0 {
sdl.push_str(", ");
}
sdl.push_str(&export_input_value(arg));
}
write!(sdl, "): {}", field.ty).ok();
} else {
write!(sdl, "\t{}: {}", field.name, field.ty).ok();
}
@ -137,7 +131,10 @@ impl Registry {
write!(sdl, "type {} ", name).ok();
if let Some(implements) = self.implements.get(name) {
if !implements.is_empty() {
write!(sdl, "implements {} ", implements.iter().join(" & ")).ok();
write!(sdl, "implements ").ok();
for interface in implements {
write!(sdl, "& {} ", interface).ok();
}
}
}
@ -223,13 +220,11 @@ impl Registry {
if description.is_some() && !federation {
writeln!(sdl, "\"\"\"\n{}\n\"\"\"", description.unwrap()).ok();
}
writeln!(
sdl,
"union {} = {}",
name,
possible_types.iter().join(" | ")
)
.ok();
write!(sdl, "union {} =", name).ok();
for ty in possible_types {
write!(sdl, " | {}", ty).ok();
}
writeln!(sdl).ok();
}
}
}

View File

@ -6,7 +6,6 @@ use std::sync::Arc;
use futures::stream::{self, Stream, StreamExt};
use indexmap::map::IndexMap;
use itertools::Itertools;
use crate::context::{Data, QueryEnvInner, ResolveId};
use crate::extensions::{ErrorLogger, ExtensionContext, ExtensionFactory, Extensions};
@ -339,7 +338,7 @@ where
.extensions
.iter()
.map(|factory| factory.create())
.collect_vec()
.collect::<Vec<_>>()
.into();
let request = extensions

View File

@ -1,9 +1,8 @@
use std::collections::HashMap;
use itertools::Itertools;
use std::fmt::Write;
fn levenshtein_distance(s1: &str, s2: &str) -> usize {
let mut column = (0..=s1.len()).collect_vec();
let mut column: Vec<_> = (0..=s1.len()).collect();
for (x, rx) in s2.bytes().enumerate() {
column[0] = x + 1;
let mut lastdiag = x;
@ -40,12 +39,20 @@ where
}
selected.sort_by(|a, b| distances[a].cmp(&distances[b]));
Some(format!(
"{} {}?",
prefix,
selected
.into_iter()
.map(|s| format!("\"{}\"", s))
.join(", ")
))
let mut suggestion = String::with_capacity(
prefix.len() + selected.iter().map(|s| s.len() + 5).sum::<usize>()
);
suggestion.push_str(prefix);
suggestion.push(' ');
for (i, s) in selected.iter().enumerate() {
if i != 0 {
suggestion.push_str(" , ");
}
write!(suggestion, "\"{}\"", s).unwrap();
}
suggestion.push('?');
Some(suggestion)
}