diff --git a/juniper/Cargo.toml b/juniper/Cargo.toml index 6eed66d9..2fda1bc1 100644 --- a/juniper/Cargo.toml +++ b/juniper/Cargo.toml @@ -35,7 +35,7 @@ default = [ juniper_codegen = { version = "0.9.2", path = "../juniper_codegen" } fnv = "1.0.3" -ordermap = { version = "0.2.11", features = ["serde-1"] } +indexmap = { version = "1.0.0", features = ["serde-1"] } serde = { version = "1.0.8" } serde_derive = {version="1.0.2" } diff --git a/juniper/src/ast.rs b/juniper/src/ast.rs index 20b08872..8d5c0ae9 100644 --- a/juniper/src/ast.rs +++ b/juniper/src/ast.rs @@ -4,7 +4,7 @@ use std::hash::Hash; use std::vec; use std::slice; -use ordermap::OrderMap; +use indexmap::IndexMap; use executor::Variables; use parser::Spanning; @@ -259,7 +259,7 @@ impl InputValue { /// /// Similar to `InputValue::list`, it makes each key and value in the given /// hash map not contain any location information. - pub fn object(o: OrderMap) -> InputValue + pub fn object(o: IndexMap) -> InputValue where K: AsRef + Eq + Hash, { @@ -356,9 +356,9 @@ impl InputValue { /// Convert the input value to an unlocated object value. /// - /// This constructs a new OrderMap that contain references to the keys + /// This constructs a new IndexMap that contain references to the keys /// and values in `self`. - pub fn to_object_value(&self) -> Option> { + pub fn to_object_value(&self) -> Option> { match *self { InputValue::Object(ref o) => Some( o.iter() diff --git a/juniper/src/executor_tests/directives.rs b/juniper/src/executor_tests/directives.rs index 5bcc53a2..197429ab 100644 --- a/juniper/src/executor_tests/directives.rs +++ b/juniper/src/executor_tests/directives.rs @@ -1,4 +1,4 @@ -use ordermap::OrderMap; +use indexmap::IndexMap; use value::Value; use executor::Variables; @@ -19,7 +19,7 @@ graphql_object!(TestType: () |&self| { fn run_variable_query(query: &str, vars: Variables, f: F) where - F: Fn(&OrderMap) -> (), + F: Fn(&IndexMap) -> (), { let schema = RootNode::new(TestType, EmptyMutation::<()>::new()); @@ -36,7 +36,7 @@ where fn run_query(query: &str, f: F) where - F: Fn(&OrderMap) -> (), + F: Fn(&IndexMap) -> (), { run_variable_query(query, Variables::new(), f); } diff --git a/juniper/src/executor_tests/enums.rs b/juniper/src/executor_tests/enums.rs index be85e5bd..daa3a4ca 100644 --- a/juniper/src/executor_tests/enums.rs +++ b/juniper/src/executor_tests/enums.rs @@ -1,4 +1,4 @@ -use ordermap::OrderMap; +use indexmap::IndexMap; use value::Value; use ast::InputValue; @@ -30,7 +30,7 @@ graphql_object!(TestType: () |&self| { fn run_variable_query(query: &str, vars: Variables, f: F) where - F: Fn(&OrderMap) -> (), + F: Fn(&IndexMap) -> (), { let schema = RootNode::new(TestType, EmptyMutation::<()>::new()); @@ -47,7 +47,7 @@ where fn run_query(query: &str, f: F) where - F: Fn(&OrderMap) -> (), + F: Fn(&IndexMap) -> (), { run_variable_query(query, Variables::new(), f); } diff --git a/juniper/src/executor_tests/executor.rs b/juniper/src/executor_tests/executor.rs index a130fec6..7b4d62ea 100644 --- a/juniper/src/executor_tests/executor.rs +++ b/juniper/src/executor_tests/executor.rs @@ -367,7 +367,7 @@ mod threads_context_correctly { } mod dynamic_context_switching { - use ordermap::OrderMap; + use indexmap::IndexMap; use value::Value; use types::scalars::EmptyMutation; @@ -382,7 +382,7 @@ mod dynamic_context_switching { } struct OuterContext { - items: OrderMap, + items: IndexMap, } impl Context for OuterContext {} diff --git a/juniper/src/executor_tests/introspection/enums.rs b/juniper/src/executor_tests/introspection/enums.rs index 5a40c342..27f378bc 100644 --- a/juniper/src/executor_tests/introspection/enums.rs +++ b/juniper/src/executor_tests/introspection/enums.rs @@ -1,4 +1,4 @@ -use ordermap::OrderMap; +use indexmap::IndexMap; use executor::Variables; use value::Value; @@ -72,7 +72,7 @@ graphql_object!(Root: () |&self| { fn run_type_info_query(doc: &str, f: F) where - F: Fn((&OrderMap, &Vec)) -> (), + F: Fn((&IndexMap, &Vec)) -> (), { let schema = RootNode::new(Root {}, EmptyMutation::<()>::new()); diff --git a/juniper/src/executor_tests/introspection/input_object.rs b/juniper/src/executor_tests/introspection/input_object.rs index 9e3586be..211fc761 100644 --- a/juniper/src/executor_tests/introspection/input_object.rs +++ b/juniper/src/executor_tests/introspection/input_object.rs @@ -1,4 +1,4 @@ -use ordermap::OrderMap; +use indexmap::IndexMap; use ast::{FromInputValue, InputValue}; use executor::Variables; @@ -99,7 +99,7 @@ graphql_object!(Root: () |&self| { fn run_type_info_query(doc: &str, f: F) where - F: Fn(&OrderMap, &Vec) -> (), + F: Fn(&IndexMap, &Vec) -> (), { let schema = RootNode::new(Root {}, EmptyMutation::<()>::new()); diff --git a/juniper/src/executor_tests/variables.rs b/juniper/src/executor_tests/variables.rs index d22e10d2..e385cfd8 100644 --- a/juniper/src/executor_tests/variables.rs +++ b/juniper/src/executor_tests/variables.rs @@ -1,4 +1,4 @@ -use ordermap::OrderMap; +use indexmap::IndexMap; use value::Value; use ast::InputValue; @@ -115,7 +115,7 @@ graphql_object!(TestType: () |&self| { fn run_variable_query(query: &str, vars: Variables, f: F) where - F: Fn(&OrderMap) -> (), + F: Fn(&IndexMap) -> (), { let schema = RootNode::new(TestType, EmptyMutation::<()>::new()); @@ -132,7 +132,7 @@ where fn run_query(query: &str, f: F) where - F: Fn(&OrderMap) -> (), + F: Fn(&IndexMap) -> (), { run_variable_query(query, Variables::new(), f); } diff --git a/juniper/src/integrations/serde.rs b/juniper/src/integrations/serde.rs index 4ffd5b60..896c7fa3 100644 --- a/juniper/src/integrations/serde.rs +++ b/juniper/src/integrations/serde.rs @@ -1,4 +1,4 @@ -use ordermap::OrderMap; +use indexmap::IndexMap; use serde::{de, ser}; use serde::ser::SerializeMap; @@ -134,7 +134,7 @@ impl<'de> de::Deserialize<'de> for InputValue { where V: de::MapAccess<'de>, { - let mut values: OrderMap = OrderMap::new(); + let mut values: IndexMap = IndexMap::new(); while let Some((key, value)) = try!(visitor.next_entry()) { values.insert(key, value); @@ -165,7 +165,7 @@ impl ser::Serialize for InputValue { .serialize(serializer), InputValue::Object(ref v) => v.iter() .map(|&(ref k, ref v)| (k.item.clone(), v.item.clone())) - .collect::>() + .collect::>() .serialize(serializer), } } @@ -218,7 +218,7 @@ impl<'a> ser::Serialize for Spanning> { try!(map.serialize_key("message")); try!(map.serialize_value(&message)); - let mut location = OrderMap::new(); + let mut location = IndexMap::new(); location.insert("line".to_owned(), self.start.line() + 1); location.insert("column".to_owned(), self.start.column() + 1); diff --git a/juniper/src/lib.rs b/juniper/src/lib.rs index 564ec5d3..8398dd72 100644 --- a/juniper/src/lib.rs +++ b/juniper/src/lib.rs @@ -98,7 +98,7 @@ extern crate serde_derive; extern crate serde_json; extern crate fnv; -extern crate ordermap; +extern crate indexmap; #[cfg(any(test, feature = "chrono"))] extern crate chrono; diff --git a/juniper/src/macros/tests/field.rs b/juniper/src/macros/tests/field.rs index 52fe43a0..9ef8b6aa 100644 --- a/juniper/src/macros/tests/field.rs +++ b/juniper/src/macros/tests/field.rs @@ -1,4 +1,4 @@ -use ordermap::OrderMap; +use indexmap::IndexMap; use value::Value; use ast::InputValue; @@ -59,7 +59,7 @@ graphql_interface!(Interface: () |&self| { fn run_field_info_query(type_name: &str, field_name: &str, f: F) where - F: Fn(&OrderMap) -> (), + F: Fn(&IndexMap) -> (), { let doc = r#" query ($typeName: String!) { diff --git a/juniper/src/macros/tests/interface.rs b/juniper/src/macros/tests/interface.rs index 4380e631..4bf19904 100644 --- a/juniper/src/macros/tests/interface.rs +++ b/juniper/src/macros/tests/interface.rs @@ -1,4 +1,4 @@ -use ordermap::OrderMap; +use indexmap::IndexMap; use std::marker::PhantomData; use ast::InputValue; @@ -130,7 +130,7 @@ graphql_object!(<'a> Root: () as "Root" |&self| { fn run_type_info_query(type_name: &str, f: F) where - F: Fn(&OrderMap, &Vec) -> (), + F: Fn(&IndexMap, &Vec) -> (), { let doc = r#" query ($typeName: String!) { diff --git a/juniper/src/macros/tests/object.rs b/juniper/src/macros/tests/object.rs index dd8dba49..f56d7a39 100644 --- a/juniper/src/macros/tests/object.rs +++ b/juniper/src/macros/tests/object.rs @@ -1,4 +1,4 @@ -use ordermap::OrderMap; +use indexmap::IndexMap; use std::marker::PhantomData; use ast::InputValue; @@ -144,7 +144,7 @@ graphql_object!(<'a> Root: InnerContext as "Root" |&self| { fn run_type_info_query(type_name: &str, f: F) where - F: Fn(&OrderMap, &Vec) -> (), + F: Fn(&IndexMap, &Vec) -> (), { let doc = r#" query ($typeName: String!) { diff --git a/juniper/src/macros/tests/scalar.rs b/juniper/src/macros/tests/scalar.rs index f417353f..8a4af913 100644 --- a/juniper/src/macros/tests/scalar.rs +++ b/juniper/src/macros/tests/scalar.rs @@ -1,4 +1,4 @@ -use ordermap::OrderMap; +use indexmap::IndexMap; use executor::Variables; use value::Value; @@ -72,7 +72,7 @@ graphql_object!(Root: () |&self| { fn run_type_info_query(doc: &str, f: F) where - F: Fn(&OrderMap) -> (), + F: Fn(&IndexMap) -> (), { let schema = RootNode::new(Root {}, EmptyMutation::<()>::new()); diff --git a/juniper/src/macros/tests/union.rs b/juniper/src/macros/tests/union.rs index 4e8261a4..86517fb7 100644 --- a/juniper/src/macros/tests/union.rs +++ b/juniper/src/macros/tests/union.rs @@ -1,4 +1,4 @@ -use ordermap::OrderMap; +use indexmap::IndexMap; use std::marker::PhantomData; use ast::InputValue; @@ -111,7 +111,7 @@ graphql_object!(<'a> Root: () as "Root" |&self| { fn run_type_info_query(type_name: &str, f: F) where - F: Fn(&OrderMap, &Vec) -> (), + F: Fn(&IndexMap, &Vec) -> (), { let doc = r#" query ($typeName: String!) { diff --git a/juniper/src/parser/tests/value.rs b/juniper/src/parser/tests/value.rs index e9d4d324..2f99eba3 100644 --- a/juniper/src/parser/tests/value.rs +++ b/juniper/src/parser/tests/value.rs @@ -1,4 +1,4 @@ -use ordermap::OrderMap; +use indexmap::IndexMap; use ast::InputValue; use parser::{Lexer, Parser, SourcePosition, Spanning}; @@ -112,7 +112,7 @@ fn input_value_literals() { Spanning::start_end( &SourcePosition::new(0, 0, 0), &SourcePosition::new(2, 0, 2), - InputValue::object(OrderMap::::new()) + InputValue::object(IndexMap::::new()) ) ); assert_eq!( diff --git a/juniper/src/tests/type_info_tests.rs b/juniper/src/tests/type_info_tests.rs index 9073cb24..5856ac6e 100644 --- a/juniper/src/tests/type_info_tests.rs +++ b/juniper/src/tests/type_info_tests.rs @@ -1,4 +1,4 @@ -use ordermap::OrderMap; +use indexmap::IndexMap; use executor::{ExecutionResult, Executor, Registry, Variables}; use value::Value; @@ -13,7 +13,7 @@ pub struct NodeTypeInfo { } pub struct Node { - attributes: OrderMap, + attributes: IndexMap, } impl GraphQLType for Node { @@ -59,7 +59,7 @@ fn test_node() { attribute_names: vec!["foo".to_string(), "bar".to_string(), "baz".to_string()], }; let mut node = Node { - attributes: OrderMap::new(), + attributes: IndexMap::new(), }; node.attributes.insert("foo".to_string(), "1".to_string()); node.attributes.insert("bar".to_string(), "2".to_string()); diff --git a/juniper/src/types/base.rs b/juniper/src/types/base.rs index 1df6d77c..7af96420 100644 --- a/juniper/src/types/base.rs +++ b/juniper/src/types/base.rs @@ -1,5 +1,5 @@ -use ordermap::OrderMap; -use ordermap::Entry; +use indexmap::IndexMap; +use indexmap::map::Entry; use ast::{Directive, FromInputValue, InputValue, Selection}; use executor::Variables; @@ -70,17 +70,17 @@ pub enum TypeKind { /// Field argument container pub struct Arguments<'a> { - args: Option>, + args: Option>, } impl<'a> Arguments<'a> { #[doc(hidden)] pub fn new( - mut args: Option>, + mut args: Option>, meta_args: &'a Option>, ) -> Arguments<'a> { if meta_args.is_some() && args.is_none() { - args = Some(OrderMap::new()); + args = Some(IndexMap::new()); } if let (&mut Some(ref mut args), &Some(ref meta_args)) = (&mut args, meta_args) { @@ -310,7 +310,7 @@ pub trait GraphQLType: Sized { executor: &Executor, ) -> Value { if let Some(selection_set) = selection_set { - let mut result = OrderMap::new(); + let mut result = IndexMap::new(); if resolve_selection_set_into(self, info, selection_set, executor, &mut result) { Value::object(result) } else { @@ -327,7 +327,7 @@ fn resolve_selection_set_into( info: &T::TypeInfo, selection_set: &[Selection], executor: &Executor, - result: &mut OrderMap, + result: &mut IndexMap, ) -> bool where T: GraphQLType, @@ -503,7 +503,7 @@ fn is_excluded(directives: &Option>>, vars: &Variables) false } -fn merge_key_into(result: &mut OrderMap, response_name: &str, value: Value) { +fn merge_key_into(result: &mut IndexMap, response_name: &str, value: Value) { match result.entry(response_name.to_owned()) { Entry::Occupied(mut e) => { match e.get_mut() { @@ -535,7 +535,7 @@ fn merge_key_into(result: &mut OrderMap, response_name: &str, val } } -fn merge_maps(dest: &mut OrderMap, src: OrderMap) { +fn merge_maps(dest: &mut IndexMap, src: IndexMap) { for (key, value) in src { if dest.contains_key(&key) { merge_key_into(dest, &key, value); diff --git a/juniper/src/value.rs b/juniper/src/value.rs index 78fe0f25..d5cbc579 100644 --- a/juniper/src/value.rs +++ b/juniper/src/value.rs @@ -1,4 +1,4 @@ -use ordermap::OrderMap; +use indexmap::IndexMap; use std::hash::Hash; use parser::Spanning; @@ -22,7 +22,7 @@ pub enum Value { String(String), Boolean(bool), List(Vec), - Object(OrderMap), + Object(IndexMap), } impl Value { @@ -59,7 +59,7 @@ impl Value { } /// Construct an object value. - pub fn object(o: OrderMap) -> Value + pub fn object(o: IndexMap) -> Value where K: Into + Eq + Hash, { @@ -85,7 +85,7 @@ impl Value { } /// View the underlying object value, if present. - pub fn as_object_value(&self) -> Option<&OrderMap> { + pub fn as_object_value(&self) -> Option<&IndexMap> { match *self { Value::Object(ref o) => Some(o), _ => None, @@ -93,7 +93,7 @@ impl Value { } /// Mutable view into the underlying object value, if present. - pub fn as_mut_object_value(&mut self) -> Option<&mut OrderMap> { + pub fn as_mut_object_value(&mut self) -> Option<&mut IndexMap> { match *self { Value::Object(ref mut o) => Some(o), _ => None,