Skip to content

Commit

Permalink
Upgrades dependencies most important serde 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tailhook committed Aug 3, 2017
1 parent a1c30d1 commit aa99fb8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ version = "0.1.1"
authors = ["paul@colomiets.name"]

[dependencies]
matches = "0.1.4"
matches = "0.1.6"
quick-error = "1.2.0"
combine = "2.0.0"
regex = "0.2.1"
serde_json = { version="0.8.3", optional=true }
combine = "2.4.0"
regex = "0.2.2"
serde_json = { version="1.0.2", optional=true }
owning_ref = "0.3.3"
argparse = "0.2.1"

[dev-dependencies]
difference = "0.4.1"
difference = "1.0.0"

[features]
default = ["serde"]
Expand Down
22 changes: 8 additions & 14 deletions src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ impl<'render> Variable<'render> for Value {
fn as_int_key(&self) -> Result<usize, DataError> {
use serde_json::Value::*;
match *self {
I64(val) if val >= 0 && val as u64 <= usize::MAX as u64
=> Ok(val as usize),
U64(val) if val <= usize::MAX as u64 => Ok(val as usize),
Number(ref val)
if val.as_u64() .map(|x| x <= usize::MAX as u64).unwrap_or(false)
=> Ok(val.as_u64().unwrap() as usize),
// TODO(tailhook) try use float too
// TODO(tailhook) show out of range int error
_ => Err(DataError::IntKeyUnsupported(self.typename())),
Expand All @@ -68,9 +68,7 @@ impl<'render> Variable<'render> for Value {
match *self {
Null => Ok(EMPTY_STR),
Bool(x) => if x { Ok(TRUE) } else { Ok(FALSE) },
I64(ref x) => Ok(x),
U64(ref x) => Ok(x),
F64(ref x) => Ok(x),
Number(ref x) => Ok(x),
String(ref s) => Ok(s),
Array(_) => Err(DataError::OutputUnsupported(self.typename())),
Object(_) => Err(DataError::OutputUnsupported(self.typename())),
Expand All @@ -81,9 +79,7 @@ impl<'render> Variable<'render> for Value {
match *self {
Null => "null",
Bool(_) => "bool",
I64(_) => "number",
U64(_) => "number",
F64(_) => "number",
Number(_) => "number",
String(_) => "string",
Array(_) => "array",
Object(_) => "object",
Expand All @@ -94,9 +90,7 @@ impl<'render> Variable<'render> for Value {
match *self {
Null => Ok(false),
Bool(x) => Ok(x),
I64(x) => Ok(x != 0),
U64(x) => Ok(x != 0),
F64(x) => Ok(x != 0.),
Number(ref x) => Ok(x.as_u64().map(|x| x != 0).unwrap_or(true)),
String(ref s) => Ok(s.len() > 0),
Array(ref a) => Ok(a.len() > 0),
Object(ref o) => Ok(o.len() > 0),
Expand All @@ -109,7 +103,7 @@ impl<'render> Variable<'render> for Value {
use serde_json::Value::*;
match *self {
Null => Ok(Box::new(empty())),
Bool(..) | I64(..) | U64(..) | F64(..) | String(..) | Object(..)
Bool(..) | Number(..) | String(..) | Object(..)
=> Err(DataError::IterationUnsupported(self.typename())),
Array(ref a) => Ok(Box::new(
a.iter().map(|x| Var::borrow(x)))),
Expand All @@ -123,7 +117,7 @@ impl<'render> Variable<'render> for Value {
use serde_json::Value::*;
match *self {
Null => Ok(Box::new(empty())),
Bool(..) | I64(..) | U64(..) | F64(..) | String(..) | Array(..)
Bool(..) | Number(..) | String(..) | Array(..)
=> Err(DataError::IterationUnsupported(self.typename())),
Object(ref o) => Ok(Box::new(
o.iter().map(|(k, v)| (Var::borrow(k), Var::borrow(v))))),
Expand Down

0 comments on commit aa99fb8

Please sign in to comment.