fix(tests): use new serde map implementation

No fun, this one.
This commit is contained in:
Sebastian Thiel
2017-02-04 13:03:42 +01:00
parent 7a611c39aa
commit 1323d0dccb
4 changed files with 12 additions and 14 deletions

View File

@@ -1,2 +1,3 @@
paths = ["/Users/byron/dev/yup-oauth2"]
[build]
target-dir = "./target"

View File

@@ -23,7 +23,7 @@ rustc-serialize = "*"
yup-oauth2 = "*"
serde = "*"
serde_json = "*"
serde_macros = "*"
serde_derive = "*"
strsim = "*"
[dev-dependencies]

View File

@@ -131,14 +131,12 @@ impl From<&'static str> for FieldCursor {
}
}
fn assure_entry<'a>(m: &'a mut json::Map<String, Value>, k: &'a String) -> &'a mut Value {
match m.get_mut(k) {
Some(v) => v,
None => {
m.insert(k.to_owned(), Value::Object(Default::default()));
m.get_mut(k).expect("value to exist")
}
fn assure_entry<'a, 'b>(m: &'a mut json::Map<String, Value>, k: &'b String) -> &'a mut Value {
if m.contains_key(k) {
return m.get_mut(k).expect("value to exist")
}
m.insert(k.to_owned(), Value::Object(Default::default()));
m.get_mut(k).expect("value to exist")
}
impl FieldCursor {
@@ -282,7 +280,7 @@ impl FieldCursor {
Value::String(value.to_owned()),
}
};
match type_info.ctype {
ComplexType::Pod => {
if mapping.insert(field.to_owned(), to_jval(value, type_info.jtype, err)).is_some() {
@@ -298,7 +296,7 @@ impl FieldCursor {
ComplexType::Map => {
let (key, value) = parse_kv_arg(value, err, true);
let jval = to_jval(value.unwrap_or(""), type_info.jtype, err);
match *assure_entry(mapping, &field) {
Value::Object(ref mut value_map) => {
@@ -314,7 +312,7 @@ impl FieldCursor {
_ => unreachable!()
}
}
pub fn num_fields(&self) -> usize {
self.0.len()
}

View File

@@ -1,7 +1,4 @@
#![feature(core,io,old_path, custom_derive, custom_attribute, plugin, slice_patterns, std_misc)]
#![allow(dead_code, deprecated, unused_features, unused_variables, unused_imports)]
//! library with code shared by all generated implementations
#![plugin(serde_macros)]
#[macro_use]
extern crate clap;
@@ -13,6 +10,8 @@ extern crate rustc_serialize;
extern crate yup_oauth2 as oauth2;
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
extern crate strsim;
// just pull it in the check if it compiles