Skip to content

Commit

Permalink
Upgrade to Rust 2018
Browse files Browse the repository at this point in the history
Since ordered-float v2 bumps the MSRV to 1.34, might as well take the
opportunity to upgrade to Rust 2018 syntax.
  • Loading branch information
benesch committed Jul 14, 2020
1 parent 559acd7 commit bad5011
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "serde-value"
version = "0.6.0"
authors = ["arcnmx"]
edition = "2018"

description = "Serialization value trees"
documentation = "http://arcnmx.github.io/serde-value/serde_value/"
Expand Down
14 changes: 7 additions & 7 deletions src/de.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use serde::de;
use serde::{forward_to_deserialize_any, de};
use std::collections::BTreeMap;
use std::error::Error;
use std::fmt;
use std::marker::PhantomData;

use Value;
use crate::Value;

#[derive(Debug)]
pub enum Unexpected {
Expand Down Expand Up @@ -96,15 +96,15 @@ impl de::Error for DeserializerError {
DeserializerError::Custom(msg.to_string())
}

fn invalid_type(unexp: de::Unexpected, exp: &de::Expected) -> Self {
fn invalid_type(unexp: de::Unexpected, exp: &dyn de::Expected) -> Self {
DeserializerError::InvalidType(unexp.into(), exp.to_string())
}

fn invalid_value(unexp: de::Unexpected, exp: &de::Expected) -> Self {
fn invalid_value(unexp: de::Unexpected, exp: &dyn de::Expected) -> Self {
DeserializerError::InvalidValue(unexp.into(), exp.to_string())
}

fn invalid_length(len: usize, exp: &de::Expected) -> Self {
fn invalid_length(len: usize, exp: &dyn de::Expected) -> Self {
DeserializerError::InvalidLength(len, exp.to_string())
}

Expand Down Expand Up @@ -268,15 +268,15 @@ impl<'de> de::Visitor<'de> for ValueVisitor {

fn visit_seq<V: de::SeqAccess<'de>>(self, mut visitor: V) -> Result<Value, V::Error> {
let mut values = Vec::new();
while let Some(elem) = try!(visitor.next_element()) {
while let Some(elem) = visitor.next_element()? {
values.push(elem);
}
Ok(Value::Seq(values))
}

fn visit_map<V: de::MapAccess<'de>>(self, mut visitor: V) -> Result<Value, V::Error> {
let mut values = BTreeMap::new();
while let Some((key, value)) = try!(visitor.next_entry()) {
while let Some((key, value)) = visitor.next_entry()? {
values.insert(key, value);
}
Ok(Value::Map(values))
Expand Down
8 changes: 0 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
#![doc(html_root_url="https://arcnmx.github.io/serde-value")]

#[macro_use]
extern crate serde;
extern crate ordered_float;

#[cfg(test)]
#[macro_use]
extern crate serde_derive;

use std::collections::BTreeMap;
use std::cmp::Ordering;
use std::hash::{Hash, Hasher};
Expand Down
2 changes: 1 addition & 1 deletion src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::BTreeMap;
use std::error::Error;
use std::fmt;

use Value;
use crate::Value;

#[derive(Debug)]
pub enum SerializerError {
Expand Down

0 comments on commit bad5011

Please sign in to comment.