Merge pull request #405 from ebkalderon/master

Update serialization to serde v1.0
This commit is contained in:
Brendan Zabarauskas 2017-04-23 10:17:59 +10:00 committed by GitHub
commit adbf511bc5
3 changed files with 30 additions and 23 deletions

View file

@ -6,6 +6,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
## [v0.13.1] - 2017-04-22
### Changed
- Update `serde` and `serde_derive` to version `1.0`.
## [v0.13.0] - 2017-04-14
### Added
@ -238,7 +244,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## v0.0.1 - 2014-06-24
[Unreleased]: https://github.com/brendanzab/cgmath/compare/v0.13.0...HEAD
[Unreleased]: https://github.com/brendanzab/cgmath/compare/v0.13.1...HEAD
[v0.13.1]: https://github.com/brendanzab/cgmath/compare/v0.13.0...v0.13.1
[v0.12.0]: https://github.com/brendanzab/cgmath/compare/v0.12.0...v0.13.0
[v0.12.0]: https://github.com/brendanzab/cgmath/compare/v0.11.0...v0.12.0
[v0.11.0]: https://github.com/brendanzab/cgmath/compare/v0.10.0...v0.11.0

View file

@ -1,7 +1,7 @@
[package]
name = "cgmath"
version = "0.13.0"
version = "0.13.1"
authors = ["Brendan Zabarauskas <bjzaba@yahoo.com.au>",
"Brian Heylin",
"Colin Sherratt",
@ -35,10 +35,10 @@ use_simd = ["simd"]
approx = "0.1"
num-traits = "0.1"
rand = "0.3"
serde = { version = "0.9", optional = true }
serde_derive = { version = "0.9", optional = true }
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
simd = { version = "0.2", optional = true }
[dev-dependencies]
glium = "0.16"
serde_json = "0.9"
serde_json = "1.0"

View file

@ -224,13 +224,13 @@ mod eders_de {
Disp,
}
impl Deserialize for DecomposedField {
impl<'a> Deserialize<'a> for DecomposedField {
fn deserialize<D>(deserializer: D) -> Result<DecomposedField, D::Error>
where D: serde::Deserializer
where D: serde::Deserializer<'a>
{
struct DecomposedFieldVisitor;
impl serde::de::Visitor for DecomposedFieldVisitor {
impl<'b> serde::de::Visitor<'b> for DecomposedFieldVisitor {
type Value = DecomposedField;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
@ -249,17 +249,17 @@ mod eders_de {
}
}
deserializer.deserialize(DecomposedFieldVisitor)
deserializer.deserialize_str(DecomposedFieldVisitor)
}
}
impl<S: VectorSpace, R> Deserialize for Decomposed<S, R>
where S: Deserialize,
S::Scalar: Deserialize,
R: Deserialize
impl<'a, S: VectorSpace, R> Deserialize<'a> for Decomposed<S, R>
where S: Deserialize<'a>,
S::Scalar: Deserialize<'a>,
R: Deserialize<'a>
{
fn deserialize<D>(deserializer: D) -> Result<Decomposed<S, R>, D::Error>
where D: serde::de::Deserializer
where D: serde::de::Deserializer<'a>
{
const FIELDS: &'static [&'static str] = &["scale", "rot", "disp"];
deserializer.deserialize_struct("Decomposed", FIELDS, DecomposedVisitor(PhantomData))
@ -268,10 +268,10 @@ mod eders_de {
struct DecomposedVisitor<S: VectorSpace, R>(PhantomData<(S, R)>);
impl<S: VectorSpace, R> serde::de::Visitor for DecomposedVisitor<S, R>
where S: Deserialize,
S::Scalar: Deserialize,
R: Deserialize
impl<'a, S: VectorSpace, R> serde::de::Visitor<'a> for DecomposedVisitor<S, R>
where S: Deserialize<'a>,
S::Scalar: Deserialize<'a>,
R: Deserialize<'a>
{
type Value = Decomposed<S, R>;
@ -280,22 +280,22 @@ mod eders_de {
}
fn visit_map<V>(self, mut visitor: V) -> Result<Decomposed<S, R>, V::Error>
where V: serde::de::MapVisitor
where V: serde::de::MapAccess<'a>
{
let mut scale = None;
let mut rot = None;
let mut disp = None;
while let Some(key) = visitor.visit_key()? {
while let Some(key) = visitor.next_key()? {
match key {
DecomposedField::Scale => {
scale = Some(visitor.visit_value()?);
scale = Some(visitor.next_value()?);
}
DecomposedField::Rot => {
rot = Some(visitor.visit_value()?);
rot = Some(visitor.next_value()?);
}
DecomposedField::Disp => {
disp = Some(visitor.visit_value()?);
disp = Some(visitor.next_value()?);
}
}
}