No bug - Revendor rust dependencies
authorServo VCS Sync <servo-vcs-sync@mozilla.com>
Tue, 23 May 2017 05:17:49 +0000
changeset 360128 09de5eeb4d2d3d3237982ff533c73dc72a53a43e
parent 360127 80aba64b0c6bf509b2a0ec499ce12f935157d7c9
child 360129 9bc41c3089925e4ef042af81b59a6269083100c5
push id31868
push userryanvm@gmail.com
push dateTue, 23 May 2017 14:32:52 +0000
treeherdermozilla-central@3a82a745123f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
No bug - Revendor rust dependencies
third_party/rust/serde-0.9.9/.cargo-checksum.json
third_party/rust/serde-0.9.9/.cargo-ok
third_party/rust/serde-0.9.9/Cargo.toml
third_party/rust/serde-0.9.9/LICENSE-APACHE
third_party/rust/serde-0.9.9/LICENSE-MIT
third_party/rust/serde-0.9.9/README.md
third_party/rust/serde-0.9.9/src/bytes.rs
third_party/rust/serde-0.9.9/src/de/content.rs
third_party/rust/serde-0.9.9/src/de/from_primitive.rs
third_party/rust/serde-0.9.9/src/de/impls.rs
third_party/rust/serde-0.9.9/src/de/mod.rs
third_party/rust/serde-0.9.9/src/de/private.rs
third_party/rust/serde-0.9.9/src/de/value.rs
third_party/rust/serde-0.9.9/src/error.rs
third_party/rust/serde-0.9.9/src/export.rs
third_party/rust/serde-0.9.9/src/iter.rs
third_party/rust/serde-0.9.9/src/lib.rs
third_party/rust/serde-0.9.9/src/macros.rs
third_party/rust/serde-0.9.9/src/ser/content.rs
third_party/rust/serde-0.9.9/src/ser/impls.rs
third_party/rust/serde-0.9.9/src/ser/impossible.rs
third_party/rust/serde-0.9.9/src/ser/mod.rs
third_party/rust/serde-0.9.9/src/ser/private.rs
third_party/rust/serde-0.9.9/src/utils.rs
third_party/rust/serde/.cargo-checksum.json
third_party/rust/serde/Cargo.toml
third_party/rust/serde/README.md
third_party/rust/serde/src/bytes.rs
third_party/rust/serde/src/de/content.rs
third_party/rust/serde/src/de/from_primitive.rs
third_party/rust/serde/src/de/ignored_any.rs
third_party/rust/serde/src/de/impls.rs
third_party/rust/serde/src/de/mod.rs
third_party/rust/serde/src/de/private.rs
third_party/rust/serde/src/de/utf8.rs
third_party/rust/serde/src/de/value.rs
third_party/rust/serde/src/error.rs
third_party/rust/serde/src/export.rs
third_party/rust/serde/src/iter.rs
third_party/rust/serde/src/lib.rs
third_party/rust/serde/src/macros.rs
third_party/rust/serde/src/private/de.rs
third_party/rust/serde/src/private/macros.rs
third_party/rust/serde/src/private/mod.rs
third_party/rust/serde/src/private/ser.rs
third_party/rust/serde/src/ser/content.rs
third_party/rust/serde/src/ser/impls.rs
third_party/rust/serde/src/ser/impossible.rs
third_party/rust/serde/src/ser/mod.rs
third_party/rust/serde/src/ser/private.rs
third_party/rust/serde/src/utils.rs
third_party/rust/serde_test/.cargo-checksum.json
third_party/rust/serde_test/.cargo-ok
third_party/rust/serde_test/Cargo.toml
third_party/rust/serde_test/LICENSE-APACHE
third_party/rust/serde_test/LICENSE-MIT
third_party/rust/serde_test/README.md
third_party/rust/serde_test/src/assert.rs
third_party/rust/serde_test/src/de.rs
third_party/rust/serde_test/src/error.rs
third_party/rust/serde_test/src/lib.rs
third_party/rust/serde_test/src/ser.rs
third_party/rust/serde_test/src/token.rs
third_party/rust/unicode-bidi-0.2.5/.cargo-checksum.json
third_party/rust/unicode-bidi-0.2.5/.cargo-ok
third_party/rust/unicode-bidi-0.2.5/.gitignore
third_party/rust/unicode-bidi-0.2.5/.travis.yml
third_party/rust/unicode-bidi-0.2.5/AUTHORS
third_party/rust/unicode-bidi-0.2.5/COPYRIGHT
third_party/rust/unicode-bidi-0.2.5/Cargo.toml
third_party/rust/unicode-bidi-0.2.5/LICENSE-APACHE
third_party/rust/unicode-bidi-0.2.5/LICENSE-MIT
third_party/rust/unicode-bidi-0.2.5/README.md
third_party/rust/unicode-bidi-0.2.5/src/lib.rs
third_party/rust/unicode-bidi-0.2.5/src/tables.rs
third_party/rust/unicode-bidi-0.2.5/tools/generate.py
third_party/rust/unicode-bidi/.cargo-checksum.json
third_party/rust/unicode-bidi/.gitignore
third_party/rust/unicode-bidi/.rustfmt.toml
third_party/rust/unicode-bidi/.travis.yml
third_party/rust/unicode-bidi/AUTHORS
third_party/rust/unicode-bidi/Cargo.toml
third_party/rust/unicode-bidi/benches/udhr.rs
third_party/rust/unicode-bidi/benches/udhr_data/README.md
third_party/rust/unicode-bidi/src/char_data/mod.rs
third_party/rust/unicode-bidi/src/char_data/tables.rs
third_party/rust/unicode-bidi/src/deprecated.rs
third_party/rust/unicode-bidi/src/explicit.rs
third_party/rust/unicode-bidi/src/format_chars.rs
third_party/rust/unicode-bidi/src/implicit.rs
third_party/rust/unicode-bidi/src/level.rs
third_party/rust/unicode-bidi/src/lib.rs
third_party/rust/unicode-bidi/src/prepare.rs
third_party/rust/unicode-bidi/src/tables.rs
third_party/rust/unicode-bidi/tests/conformance_tests.rs
third_party/rust/unicode-bidi/tools/generate.py
toolkit/library/gtest/rust/Cargo.lock
toolkit/library/rust/Cargo.lock
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde-0.9.9/.cargo-checksum.json
@@ -0,0 +1,1 @@
+{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"e2817af66db5f058a55b5f126ca9a663925bfeb36a592a4121e7e9a44d3a3453","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"ebe318a04cf4e547e0f3ab97f1345ecb553358ee13ea81f99e3323e37d70ccdf","src/bytes.rs":"2b6a9c2c3d6eabe8633adee6655a3b94f0d1e931e740e72699b6965bee21e226","src/de/content.rs":"469d3298d4109d514a8cd630273a288a361544979e2ab23aaa325b2201f9361f","src/de/from_primitive.rs":"b1bd165e343a4380965551709119ef9ed895e4b025045a810dabd671511ba3ab","src/de/impls.rs":"762c3f32627d12555ccd08fcdf3dfb621403c35cde8a5af7866e2ad74c95a4c8","src/de/mod.rs":"365ee7038c53e88cddd451afd11d459f65185fd04523bd000a6b424ac4f71db7","src/de/private.rs":"2578dbc89c2f2a852caed3fdc40f710d4828d085c4e954dd96789d678583424e","src/de/value.rs":"67a34c03fda6521c082548984b0116494e5fbff7e60e30e06f0dda62d9d3e083","src/error.rs":"3af5286c1daad9bfd504693f8a8587f7044c9b9520e23e072549c43a72e4821d","src/export.rs":"0b8e6b642010ad6a71f13f5facfd91e9da1d7c99d479dba020dec10e88fb6b0f","src/iter.rs":"af3c43712c240b3a06870e0b0b6e837b142d5a65c62742fa358fe36a9d9319a7","src/lib.rs":"75df159c150e62c99887c0a4f23ed1271c9eb910ebc79a2d4bd279b0e11ce7e3","src/macros.rs":"af1f75bb34460b814e44f7bc67bdd1dc1bba97f1f2a31744c22e1bfcdc29499a","src/ser/content.rs":"f1cd3724e5ddeacb75b3585b2fd2be7c42fc764444b1f764e31ed9fe49f62025","src/ser/impls.rs":"51d4036b8309381af8267375778bf80c3a9114577c03a04da9a679462077efac","src/ser/impossible.rs":"f1332a1250f9c1d85d679653ade502cf99bdff0344b9f864e6cf1a1789d7c597","src/ser/mod.rs":"d1d821488453651a986bb4e4608f72868c09a71a8dbf693584758b25603ae8bf","src/ser/private.rs":"3999dc19d61d43a64d5d1bdda61f80ea16405a926b074b5441b39d87318be73b","src/utils.rs":"ed271c0825c01d7b24968bf47ce9e2475ca219faf733eb33831d6e19bf07aaf1"},"package":"05a67b8a53f885f4b6e3ed183806035819f9862474e747fe4488a6d63bcbfcb7"}
\ No newline at end of file
new file mode 100644
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde-0.9.9/Cargo.toml
@@ -0,0 +1,34 @@
+[package]
+name = "serde"
+version = "0.9.9"
+authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
+license = "MIT/Apache-2.0"
+description = "A generic serialization/deserialization framework"
+homepage = "https://serde.rs"
+repository = "https://github.com/serde-rs/serde"
+documentation = "https://docs.serde.rs/serde/"
+keywords = ["serde", "serialization", "no_std"]
+categories = ["encoding"]
+readme = "../README.md"
+include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
+
+[badges]
+travis-ci = { repository = "serde-rs/serde" }
+
+[features]
+default = ["std"]
+
+std = []
+unstable = []
+alloc = ["unstable"]
+collections = ["alloc"]
+unstable-testing = ["unstable", "std"]
+
+# to get serde_derive picked up by play.integer32.com
+playground = ["serde_derive"]
+
+[dependencies]
+serde_derive = { version = "0.9", optional = true }
+
+[dev-dependencies]
+serde_derive = "0.9"
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde-0.9.9/LICENSE-APACHE
@@ -0,0 +1,201 @@
+                              Apache License
+                        Version 2.0, January 2004
+                     http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+   "License" shall mean the terms and conditions for use, reproduction,
+   and distribution as defined by Sections 1 through 9 of this document.
+
+   "Licensor" shall mean the copyright owner or entity authorized by
+   the copyright owner that is granting the License.
+
+   "Legal Entity" shall mean the union of the acting entity and all
+   other entities that control, are controlled by, or are under common
+   control with that entity. For the purposes of this definition,
+   "control" means (i) the power, direct or indirect, to cause the
+   direction or management of such entity, whether by contract or
+   otherwise, or (ii) ownership of fifty percent (50%) or more of the
+   outstanding shares, or (iii) beneficial ownership of such entity.
+
+   "You" (or "Your") shall mean an individual or Legal Entity
+   exercising permissions granted by this License.
+
+   "Source" form shall mean the preferred form for making modifications,
+   including but not limited to software source code, documentation
+   source, and configuration files.
+
+   "Object" form shall mean any form resulting from mechanical
+   transformation or translation of a Source form, including but
+   not limited to compiled object code, generated documentation,
+   and conversions to other media types.
+
+   "Work" shall mean the work of authorship, whether in Source or
+   Object form, made available under the License, as indicated by a
+   copyright notice that is included in or attached to the work
+   (an example is provided in the Appendix below).
+
+   "Derivative Works" shall mean any work, whether in Source or Object
+   form, that is based on (or derived from) the Work and for which the
+   editorial revisions, annotations, elaborations, or other modifications
+   represent, as a whole, an original work of authorship. For the purposes
+   of this License, Derivative Works shall not include works that remain
+   separable from, or merely link (or bind by name) to the interfaces of,
+   the Work and Derivative Works thereof.
+
+   "Contribution" shall mean any work of authorship, including
+   the original version of the Work and any modifications or additions
+   to that Work or Derivative Works thereof, that is intentionally
+   submitted to Licensor for inclusion in the Work by the copyright owner
+   or by an individual or Legal Entity authorized to submit on behalf of
+   the copyright owner. For the purposes of this definition, "submitted"
+   means any form of electronic, verbal, or written communication sent
+   to the Licensor or its representatives, including but not limited to
+   communication on electronic mailing lists, source code control systems,
+   and issue tracking systems that are managed by, or on behalf of, the
+   Licensor for the purpose of discussing and improving the Work, but
+   excluding communication that is conspicuously marked or otherwise
+   designated in writing by the copyright owner as "Not a Contribution."
+
+   "Contributor" shall mean Licensor and any individual or Legal Entity
+   on behalf of whom a Contribution has been received by Licensor and
+   subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+   this License, each Contributor hereby grants to You a perpetual,
+   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+   copyright license to reproduce, prepare Derivative Works of,
+   publicly display, publicly perform, sublicense, and distribute the
+   Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+   this License, each Contributor hereby grants to You a perpetual,
+   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+   (except as stated in this section) patent license to make, have made,
+   use, offer to sell, sell, import, and otherwise transfer the Work,
+   where such license applies only to those patent claims licensable
+   by such Contributor that are necessarily infringed by their
+   Contribution(s) alone or by combination of their Contribution(s)
+   with the Work to which such Contribution(s) was submitted. If You
+   institute patent litigation against any entity (including a
+   cross-claim or counterclaim in a lawsuit) alleging that the Work
+   or a Contribution incorporated within the Work constitutes direct
+   or contributory patent infringement, then any patent licenses
+   granted to You under this License for that Work shall terminate
+   as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+   Work or Derivative Works thereof in any medium, with or without
+   modifications, and in Source or Object form, provided that You
+   meet the following conditions:
+
+   (a) You must give any other recipients of the Work or
+       Derivative Works a copy of this License; and
+
+   (b) You must cause any modified files to carry prominent notices
+       stating that You changed the files; and
+
+   (c) You must retain, in the Source form of any Derivative Works
+       that You distribute, all copyright, patent, trademark, and
+       attribution notices from the Source form of the Work,
+       excluding those notices that do not pertain to any part of
+       the Derivative Works; and
+
+   (d) If the Work includes a "NOTICE" text file as part of its
+       distribution, then any Derivative Works that You distribute must
+       include a readable copy of the attribution notices contained
+       within such NOTICE file, excluding those notices that do not
+       pertain to any part of the Derivative Works, in at least one
+       of the following places: within a NOTICE text file distributed
+       as part of the Derivative Works; within the Source form or
+       documentation, if provided along with the Derivative Works; or,
+       within a display generated by the Derivative Works, if and
+       wherever such third-party notices normally appear. The contents
+       of the NOTICE file are for informational purposes only and
+       do not modify the License. You may add Your own attribution
+       notices within Derivative Works that You distribute, alongside
+       or as an addendum to the NOTICE text from the Work, provided
+       that such additional attribution notices cannot be construed
+       as modifying the License.
+
+   You may add Your own copyright statement to Your modifications and
+   may provide additional or different license terms and conditions
+   for use, reproduction, or distribution of Your modifications, or
+   for any such Derivative Works as a whole, provided Your use,
+   reproduction, and distribution of the Work otherwise complies with
+   the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+   any Contribution intentionally submitted for inclusion in the Work
+   by You to the Licensor shall be under the terms and conditions of
+   this License, without any additional terms or conditions.
+   Notwithstanding the above, nothing herein shall supersede or modify
+   the terms of any separate license agreement you may have executed
+   with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+   names, trademarks, service marks, or product names of the Licensor,
+   except as required for reasonable and customary use in describing the
+   origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+   agreed to in writing, Licensor provides the Work (and each
+   Contributor provides its Contributions) on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+   implied, including, without limitation, any warranties or conditions
+   of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+   PARTICULAR PURPOSE. You are solely responsible for determining the
+   appropriateness of using or redistributing the Work and assume any
+   risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+   whether in tort (including negligence), contract, or otherwise,
+   unless required by applicable law (such as deliberate and grossly
+   negligent acts) or agreed to in writing, shall any Contributor be
+   liable to You for damages, including any direct, indirect, special,
+   incidental, or consequential damages of any character arising as a
+   result of this License or out of the use or inability to use the
+   Work (including but not limited to damages for loss of goodwill,
+   work stoppage, computer failure or malfunction, or any and all
+   other commercial damages or losses), even if such Contributor
+   has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+   the Work or Derivative Works thereof, You may choose to offer,
+   and charge a fee for, acceptance of support, warranty, indemnity,
+   or other liability obligations and/or rights consistent with this
+   License. However, in accepting such obligations, You may act only
+   on Your own behalf and on Your sole responsibility, not on behalf
+   of any other Contributor, and only if You agree to indemnify,
+   defend, and hold each Contributor harmless for any liability
+   incurred by, or claims asserted against, such Contributor by reason
+   of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+   To apply the Apache License to your work, attach the following
+   boilerplate notice, with the fields enclosed by brackets "[]"
+   replaced with your own identifying information. (Don't include
+   the brackets!)  The text should be enclosed in the appropriate
+   comment syntax for the file format. We also recommend that a
+   file or class name and description of purpose be included on the
+   same "printed page" as the copyright notice for easier
+   identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+	http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde-0.9.9/LICENSE-MIT
@@ -0,0 +1,25 @@
+Copyright (c) 2014 The Rust Project Developers
+
+Permission is hereby granted, free of charge, to any
+person obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without
+limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software
+is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde-0.9.9/README.md
@@ -0,0 +1,71 @@
+# Serde &emsp; [![Build Status](https://api.travis-ci.org/serde-rs/serde.svg?branch=master)](https://travis-ci.org/serde-rs/serde) [![Latest Version](https://img.shields.io/crates/v/serde.svg)](https://crates.io/crates/serde)
+
+**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
+
+---
+
+You may be looking for:
+
+- [An overview of Serde](https://serde.rs/)
+- [Data formats supported by Serde](https://serde.rs/#data-formats)
+- [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/codegen.html)
+- [Examples](https://serde.rs/examples.html)
+- [API documentation](https://docs.serde.rs/serde/)
+- [Release notes](https://github.com/serde-rs/serde/releases)
+
+## Serde in action
+
+```rust
+#[macro_use]
+extern crate serde_derive;
+
+extern crate serde_json;
+
+#[derive(Serialize, Deserialize, Debug)]
+struct Point {
+    x: i32,
+    y: i32,
+}
+
+fn main() {
+    let point = Point { x: 1, y: 2 };
+
+    // Convert the Point to a JSON string.
+    let serialized = serde_json::to_string(&point).unwrap();
+
+    // Prints serialized = {"x":1,"y":2}
+    println!("serialized = {}", serialized);
+
+    // Convert the JSON string back to a Point.
+    let deserialized: Point = serde_json::from_str(&serialized).unwrap();
+
+    // Prints deserialized = Point { x: 1, y: 2 }
+    println!("deserialized = {:?}", deserialized);
+}
+```
+
+## Getting help
+
+Serde developers live in the #serde channel on
+[`irc.mozilla.org`](https://wiki.mozilla.org/IRC). The #rust channel is also a
+good resource with generally faster response time but less specific knowledge
+about Serde. If IRC is not your thing or you don't get a good response, we are
+happy to respond to [GitHub issues](https://github.com/serde-rs/serde/issues/new)
+as well.
+
+## License
+
+Serde is licensed under either of
+
+ * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
+   http://www.apache.org/licenses/LICENSE-2.0)
+ * MIT license ([LICENSE-MIT](LICENSE-MIT) or
+   http://opensource.org/licenses/MIT)
+
+at your option.
+
+### Contribution
+
+Unless you explicitly state otherwise, any contribution intentionally submitted
+for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be
+dual licensed as above, without any additional terms or conditions.
rename from third_party/rust/serde/src/bytes.rs
rename to third_party/rust/serde-0.9.9/src/bytes.rs
rename from third_party/rust/serde/src/de/content.rs
rename to third_party/rust/serde-0.9.9/src/de/content.rs
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde-0.9.9/src/de/from_primitive.rs
@@ -0,0 +1,409 @@
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Extracted from https://github.com/rust-num/num.
+
+// Rust 1.5 is unhappy that this private module is undocumented.
+#![allow(missing_docs)]
+
+use core::{usize, u8, u16, u32, u64};
+use core::{isize, i8, i16, i32, i64};
+use core::{f32, f64};
+use core::mem::size_of;
+
+/// Numbers which have upper and lower bounds
+pub trait Bounded {
+    // FIXME (#5527): These should be associated constants
+    /// returns the smallest finite number this type can represent
+    fn min_value() -> Self;
+    /// returns the largest finite number this type can represent
+    fn max_value() -> Self;
+}
+
+macro_rules! bounded_impl {
+    ($t:ty, $min:expr, $max:expr) => {
+        impl Bounded for $t {
+            #[inline]
+            fn min_value() -> $t { $min }
+
+            #[inline]
+            fn max_value() -> $t { $max }
+        }
+    }
+}
+
+bounded_impl!(usize, usize::MIN, usize::MAX);
+bounded_impl!(u8, u8::MIN, u8::MAX);
+bounded_impl!(u16, u16::MIN, u16::MAX);
+bounded_impl!(u32, u32::MIN, u32::MAX);
+bounded_impl!(u64, u64::MIN, u64::MAX);
+
+bounded_impl!(isize, isize::MIN, isize::MAX);
+bounded_impl!(i8, i8::MIN, i8::MAX);
+bounded_impl!(i16, i16::MIN, i16::MAX);
+bounded_impl!(i32, i32::MIN, i32::MAX);
+bounded_impl!(i64, i64::MIN, i64::MAX);
+
+bounded_impl!(f32, f32::MIN, f32::MAX);
+bounded_impl!(f64, f64::MIN, f64::MAX);
+
+/// A generic trait for converting a value to a number.
+pub trait ToPrimitive {
+    /// Converts the value of `self` to an `isize`.
+    #[inline]
+    fn to_isize(&self) -> Option<isize> {
+        self.to_i64().and_then(|x| x.to_isize())
+    }
+
+    /// Converts the value of `self` to an `i8`.
+    #[inline]
+    fn to_i8(&self) -> Option<i8> {
+        self.to_i64().and_then(|x| x.to_i8())
+    }
+
+    /// Converts the value of `self` to an `i16`.
+    #[inline]
+    fn to_i16(&self) -> Option<i16> {
+        self.to_i64().and_then(|x| x.to_i16())
+    }
+
+    /// Converts the value of `self` to an `i32`.
+    #[inline]
+    fn to_i32(&self) -> Option<i32> {
+        self.to_i64().and_then(|x| x.to_i32())
+    }
+
+    /// Converts the value of `self` to an `i64`.
+    fn to_i64(&self) -> Option<i64>;
+
+    /// Converts the value of `self` to a `usize`.
+    #[inline]
+    fn to_usize(&self) -> Option<usize> {
+        self.to_u64().and_then(|x| x.to_usize())
+    }
+
+    /// Converts the value of `self` to an `u8`.
+    #[inline]
+    fn to_u8(&self) -> Option<u8> {
+        self.to_u64().and_then(|x| x.to_u8())
+    }
+
+    /// Converts the value of `self` to an `u16`.
+    #[inline]
+    fn to_u16(&self) -> Option<u16> {
+        self.to_u64().and_then(|x| x.to_u16())
+    }
+
+    /// Converts the value of `self` to an `u32`.
+    #[inline]
+    fn to_u32(&self) -> Option<u32> {
+        self.to_u64().and_then(|x| x.to_u32())
+    }
+
+    /// Converts the value of `self` to an `u64`.
+    #[inline]
+    fn to_u64(&self) -> Option<u64>;
+
+    /// Converts the value of `self` to an `f32`.
+    #[inline]
+    fn to_f32(&self) -> Option<f32> {
+        self.to_f64().and_then(|x| x.to_f32())
+    }
+
+    /// Converts the value of `self` to an `f64`.
+    #[inline]
+    fn to_f64(&self) -> Option<f64> {
+        self.to_i64().and_then(|x| x.to_f64())
+    }
+}
+
+macro_rules! impl_to_primitive_int_to_int {
+    ($SrcT:ty, $DstT:ty, $slf:expr) => (
+        {
+            if size_of::<$SrcT>() <= size_of::<$DstT>() {
+                Some($slf as $DstT)
+            } else {
+                let n = $slf as i64;
+                let min_value: $DstT = Bounded::min_value();
+                let max_value: $DstT = Bounded::max_value();
+                if min_value as i64 <= n && n <= max_value as i64 {
+                    Some($slf as $DstT)
+                } else {
+                    None
+                }
+            }
+        }
+    )
+}
+
+macro_rules! impl_to_primitive_int_to_uint {
+    ($SrcT:ty, $DstT:ty, $slf:expr) => (
+        {
+            let zero: $SrcT = 0;
+            let max_value: $DstT = Bounded::max_value();
+            if zero <= $slf && $slf as u64 <= max_value as u64 {
+                Some($slf as $DstT)
+            } else {
+                None
+            }
+        }
+    )
+}
+
+macro_rules! impl_to_primitive_int {
+    ($T:ty) => (
+        impl ToPrimitive for $T {
+            #[inline]
+            fn to_isize(&self) -> Option<isize> { impl_to_primitive_int_to_int!($T, isize, *self) }
+            #[inline]
+            fn to_i8(&self) -> Option<i8> { impl_to_primitive_int_to_int!($T, i8, *self) }
+            #[inline]
+            fn to_i16(&self) -> Option<i16> { impl_to_primitive_int_to_int!($T, i16, *self) }
+            #[inline]
+            fn to_i32(&self) -> Option<i32> { impl_to_primitive_int_to_int!($T, i32, *self) }
+            #[inline]
+            fn to_i64(&self) -> Option<i64> { impl_to_primitive_int_to_int!($T, i64, *self) }
+
+            #[inline]
+            fn to_usize(&self) -> Option<usize> { impl_to_primitive_int_to_uint!($T, usize, *self) }
+            #[inline]
+            fn to_u8(&self) -> Option<u8> { impl_to_primitive_int_to_uint!($T, u8, *self) }
+            #[inline]
+            fn to_u16(&self) -> Option<u16> { impl_to_primitive_int_to_uint!($T, u16, *self) }
+            #[inline]
+            fn to_u32(&self) -> Option<u32> { impl_to_primitive_int_to_uint!($T, u32, *self) }
+            #[inline]
+            fn to_u64(&self) -> Option<u64> { impl_to_primitive_int_to_uint!($T, u64, *self) }
+
+            #[inline]
+            fn to_f32(&self) -> Option<f32> { Some(*self as f32) }
+            #[inline]
+            fn to_f64(&self) -> Option<f64> { Some(*self as f64) }
+        }
+    )
+}
+
+impl_to_primitive_int! { isize }
+impl_to_primitive_int! { i8 }
+impl_to_primitive_int! { i16 }
+impl_to_primitive_int! { i32 }
+impl_to_primitive_int! { i64 }
+
+macro_rules! impl_to_primitive_uint_to_int {
+    ($DstT:ty, $slf:expr) => (
+        {
+            let max_value: $DstT = Bounded::max_value();
+            if $slf as u64 <= max_value as u64 {
+                Some($slf as $DstT)
+            } else {
+                None
+            }
+        }
+    )
+}
+
+macro_rules! impl_to_primitive_uint_to_uint {
+    ($SrcT:ty, $DstT:ty, $slf:expr) => (
+        {
+            if size_of::<$SrcT>() <= size_of::<$DstT>() {
+                Some($slf as $DstT)
+            } else {
+                let zero: $SrcT = 0;
+                let max_value: $DstT = Bounded::max_value();
+                if zero <= $slf && $slf as u64 <= max_value as u64 {
+                    Some($slf as $DstT)
+                } else {
+                    None
+                }
+            }
+        }
+    )
+}
+
+macro_rules! impl_to_primitive_uint {
+    ($T:ty) => (
+        impl ToPrimitive for $T {
+            #[inline]
+            fn to_isize(&self) -> Option<isize> { impl_to_primitive_uint_to_int!(isize, *self) }
+            #[inline]
+            fn to_i8(&self) -> Option<i8> { impl_to_primitive_uint_to_int!(i8, *self) }
+            #[inline]
+            fn to_i16(&self) -> Option<i16> { impl_to_primitive_uint_to_int!(i16, *self) }
+            #[inline]
+            fn to_i32(&self) -> Option<i32> { impl_to_primitive_uint_to_int!(i32, *self) }
+            #[inline]
+            fn to_i64(&self) -> Option<i64> { impl_to_primitive_uint_to_int!(i64, *self) }
+
+            #[inline]
+            fn to_usize(&self) -> Option<usize> {
+                impl_to_primitive_uint_to_uint!($T, usize, *self)
+            }
+            #[inline]
+            fn to_u8(&self) -> Option<u8> { impl_to_primitive_uint_to_uint!($T, u8, *self) }
+            #[inline]
+            fn to_u16(&self) -> Option<u16> { impl_to_primitive_uint_to_uint!($T, u16, *self) }
+            #[inline]
+            fn to_u32(&self) -> Option<u32> { impl_to_primitive_uint_to_uint!($T, u32, *self) }
+            #[inline]
+            fn to_u64(&self) -> Option<u64> { impl_to_primitive_uint_to_uint!($T, u64, *self) }
+
+            #[inline]
+            fn to_f32(&self) -> Option<f32> { Some(*self as f32) }
+            #[inline]
+            fn to_f64(&self) -> Option<f64> { Some(*self as f64) }
+        }
+    )
+}
+
+impl_to_primitive_uint! { usize }
+impl_to_primitive_uint! { u8 }
+impl_to_primitive_uint! { u16 }
+impl_to_primitive_uint! { u32 }
+impl_to_primitive_uint! { u64 }
+
+macro_rules! impl_to_primitive_float_to_float {
+    ($SrcT:ident, $DstT:ident, $slf:expr) => (
+        if size_of::<$SrcT>() <= size_of::<$DstT>() {
+            Some($slf as $DstT)
+        } else {
+            let n = $slf as f64;
+            let max_value: $SrcT = ::core::$SrcT::MAX;
+            if -max_value as f64 <= n && n <= max_value as f64 {
+                Some($slf as $DstT)
+            } else {
+                None
+            }
+        }
+    )
+}
+
+macro_rules! impl_to_primitive_float {
+    ($T:ident) => (
+        impl ToPrimitive for $T {
+            #[inline]
+            fn to_isize(&self) -> Option<isize> { Some(*self as isize) }
+            #[inline]
+            fn to_i8(&self) -> Option<i8> { Some(*self as i8) }
+            #[inline]
+            fn to_i16(&self) -> Option<i16> { Some(*self as i16) }
+            #[inline]
+            fn to_i32(&self) -> Option<i32> { Some(*self as i32) }
+            #[inline]
+            fn to_i64(&self) -> Option<i64> { Some(*self as i64) }
+
+            #[inline]
+            fn to_usize(&self) -> Option<usize> { Some(*self as usize) }
+            #[inline]
+            fn to_u8(&self) -> Option<u8> { Some(*self as u8) }
+            #[inline]
+            fn to_u16(&self) -> Option<u16> { Some(*self as u16) }
+            #[inline]
+            fn to_u32(&self) -> Option<u32> { Some(*self as u32) }
+            #[inline]
+            fn to_u64(&self) -> Option<u64> { Some(*self as u64) }
+
+            #[inline]
+            fn to_f32(&self) -> Option<f32> { impl_to_primitive_float_to_float!($T, f32, *self) }
+            #[inline]
+            fn to_f64(&self) -> Option<f64> { impl_to_primitive_float_to_float!($T, f64, *self) }
+        }
+    )
+}
+
+impl_to_primitive_float! { f32 }
+impl_to_primitive_float! { f64 }
+
+pub trait FromPrimitive: Sized {
+    #[inline]
+    fn from_isize(n: isize) -> Option<Self> {
+        FromPrimitive::from_i64(n as i64)
+    }
+
+    #[inline]
+    fn from_i8(n: i8) -> Option<Self> {
+        FromPrimitive::from_i64(n as i64)
+    }
+
+    #[inline]
+    fn from_i16(n: i16) -> Option<Self> {
+        FromPrimitive::from_i64(n as i64)
+    }
+
+    #[inline]
+    fn from_i32(n: i32) -> Option<Self> {
+        FromPrimitive::from_i64(n as i64)
+    }
+
+    fn from_i64(n: i64) -> Option<Self>;
+
+    #[inline]
+    fn from_usize(n: usize) -> Option<Self> {
+        FromPrimitive::from_u64(n as u64)
+    }
+
+    #[inline]
+    fn from_u8(n: u8) -> Option<Self> {
+        FromPrimitive::from_u64(n as u64)
+    }
+
+    #[inline]
+    fn from_u16(n: u16) -> Option<Self> {
+        FromPrimitive::from_u64(n as u64)
+    }
+
+    #[inline]
+    fn from_u32(n: u32) -> Option<Self> {
+        FromPrimitive::from_u64(n as u64)
+    }
+
+    fn from_u64(n: u64) -> Option<Self>;
+
+    #[inline]
+    fn from_f32(n: f32) -> Option<Self> {
+        FromPrimitive::from_f64(n as f64)
+    }
+
+    #[inline]
+    fn from_f64(n: f64) -> Option<Self> {
+        FromPrimitive::from_i64(n as i64)
+    }
+}
+
+macro_rules! impl_from_primitive {
+    ($T:ty, $to_ty:ident) => (
+        impl FromPrimitive for $T {
+            #[inline] fn from_i8(n: i8) -> Option<$T> { n.$to_ty() }
+            #[inline] fn from_i16(n: i16) -> Option<$T> { n.$to_ty() }
+            #[inline] fn from_i32(n: i32) -> Option<$T> { n.$to_ty() }
+            #[inline] fn from_i64(n: i64) -> Option<$T> { n.$to_ty() }
+
+            #[inline] fn from_u8(n: u8) -> Option<$T> { n.$to_ty() }
+            #[inline] fn from_u16(n: u16) -> Option<$T> { n.$to_ty() }
+            #[inline] fn from_u32(n: u32) -> Option<$T> { n.$to_ty() }
+            #[inline] fn from_u64(n: u64) -> Option<$T> { n.$to_ty() }
+
+            #[inline] fn from_f32(n: f32) -> Option<$T> { n.$to_ty() }
+            #[inline] fn from_f64(n: f64) -> Option<$T> { n.$to_ty() }
+        }
+    )
+}
+
+impl_from_primitive! { isize, to_isize }
+impl_from_primitive! { i8, to_i8 }
+impl_from_primitive! { i16, to_i16 }
+impl_from_primitive! { i32, to_i32 }
+impl_from_primitive! { i64, to_i64 }
+impl_from_primitive! { usize, to_usize }
+impl_from_primitive! { u8, to_u8 }
+impl_from_primitive! { u16, to_u16 }
+impl_from_primitive! { u32, to_u32 }
+impl_from_primitive! { u64, to_u64 }
+impl_from_primitive! { f32, to_f32 }
+impl_from_primitive! { f64, to_f64 }
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde-0.9.9/src/de/impls.rs
@@ -0,0 +1,1303 @@
+//! This module contains `Deserialize` and `Visitor` implementations.
+
+#[cfg(feature = "std")]
+use std::borrow::Cow;
+#[cfg(all(feature = "collections", not(feature = "std")))]
+use collections::borrow::Cow;
+
+#[cfg(all(feature = "collections", not(feature = "std")))]
+use collections::{BinaryHeap, BTreeMap, BTreeSet, LinkedList, VecDeque, Vec, String};
+
+#[cfg(feature = "std")]
+use std::collections::{HashMap, HashSet, BinaryHeap, BTreeMap, BTreeSet, LinkedList, VecDeque};
+
+#[cfg(feature = "collections")]
+use collections::borrow::ToOwned;
+
+#[cfg(any(feature = "std", feature = "collections"))]
+use core::cmp;
+use core::fmt;
+#[cfg(feature = "std")]
+use core::hash::{Hash, BuildHasher};
+use core::marker::PhantomData;
+#[cfg(feature = "std")]
+use std::net;
+#[cfg(feature = "std")]
+use std::path;
+use core::str;
+
+#[cfg(feature = "std")]
+use std::rc::Rc;
+#[cfg(all(feature = "alloc", not(feature = "std")))]
+use alloc::rc::Rc;
+
+#[cfg(feature = "std")]
+use std::sync::Arc;
+#[cfg(all(feature = "alloc", not(feature = "std")))]
+use alloc::arc::Arc;
+
+#[cfg(all(feature = "alloc", not(feature = "std")))]
+use alloc::boxed::Box;
+
+#[cfg(feature = "std")]
+use std::time::Duration;
+
+#[cfg(feature = "unstable")]
+use core::nonzero::{NonZero, Zeroable};
+
+#[cfg(feature = "unstable")]
+#[allow(deprecated)] // required for impl Deserialize for NonZero<T>
+use core::num::Zero;
+
+use de::{Deserialize, Deserializer, EnumVisitor, Error, MapVisitor, SeqVisitor, Unexpected,
+         VariantVisitor, Visitor};
+use de::from_primitive::FromPrimitive;
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// A visitor that produces a `()`.
+pub struct UnitVisitor;
+
+impl Visitor for UnitVisitor {
+    type Value = ();
+
+    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        formatter.write_str("unit")
+    }
+
+    fn visit_unit<E>(self) -> Result<(), E>
+        where E: Error
+    {
+        Ok(())
+    }
+
+    fn visit_seq<V>(self, _: V) -> Result<(), V::Error>
+        where V: SeqVisitor
+    {
+        Ok(())
+    }
+}
+
+impl Deserialize for () {
+    fn deserialize<D>(deserializer: D) -> Result<(), D::Error>
+        where D: Deserializer
+    {
+        deserializer.deserialize_unit(UnitVisitor)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// A visitor that produces a `bool`.
+pub struct BoolVisitor;
+
+impl Visitor for BoolVisitor {
+    type Value = bool;
+
+    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        formatter.write_str("a boolean")
+    }
+
+    fn visit_bool<E>(self, v: bool) -> Result<bool, E>
+        where E: Error
+    {
+        Ok(v)
+    }
+
+    fn visit_str<E>(self, s: &str) -> Result<bool, E>
+        where E: Error
+    {
+        match s.trim_matches(::utils::Pattern_White_Space) {
+            "true" => Ok(true),
+            "false" => Ok(false),
+            _ => Err(Error::invalid_type(Unexpected::Str(s), &self)),
+        }
+    }
+}
+
+impl Deserialize for bool {
+    fn deserialize<D>(deserializer: D) -> Result<bool, D::Error>
+        where D: Deserializer
+    {
+        deserializer.deserialize_bool(BoolVisitor)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+macro_rules! impl_deserialize_num_method {
+    ($ty:ident, $src_ty:ident, $method:ident, $from_method:ident, $group:ident, $group_ty:ident) => {
+        #[inline]
+        fn $method<E>(self, v: $src_ty) -> Result<$ty, E>
+            where E: Error,
+        {
+            match FromPrimitive::$from_method(v) {
+                Some(v) => Ok(v),
+                None => Err(Error::invalid_value(Unexpected::$group(v as $group_ty), &self)),
+            }
+        }
+    }
+}
+
+macro_rules! impl_deserialize_num {
+    ($ty:ident, $method:ident) => {
+        impl Deserialize for $ty {
+            #[inline]
+            fn deserialize<D>(deserializer: D) -> Result<$ty, D::Error>
+                where D: Deserializer,
+            {
+                struct PrimitiveVisitor;
+
+                impl Visitor for PrimitiveVisitor {
+                    type Value = $ty;
+
+                    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                        formatter.write_str(stringify!($ty))
+                    }
+
+                    impl_deserialize_num_method!($ty, i8, visit_i8, from_i8, Signed, i64);
+                    impl_deserialize_num_method!($ty, i16, visit_i16, from_i16, Signed, i64);
+                    impl_deserialize_num_method!($ty, i32, visit_i32, from_i32, Signed, i64);
+                    impl_deserialize_num_method!($ty, i64, visit_i64, from_i64, Signed, i64);
+                    impl_deserialize_num_method!($ty, u8, visit_u8, from_u8, Unsigned, u64);
+                    impl_deserialize_num_method!($ty, u16, visit_u16, from_u16, Unsigned, u64);
+                    impl_deserialize_num_method!($ty, u32, visit_u32, from_u32, Unsigned, u64);
+                    impl_deserialize_num_method!($ty, u64, visit_u64, from_u64, Unsigned, u64);
+                    impl_deserialize_num_method!($ty, f32, visit_f32, from_f32, Float, f64);
+                    impl_deserialize_num_method!($ty, f64, visit_f64, from_f64, Float, f64);
+
+                    #[inline]
+                    fn visit_str<E>(self, s: &str) -> Result<$ty, E>
+                        where E: Error,
+                    {
+                        str::FromStr::from_str(s.trim_matches(::utils::Pattern_White_Space)).or_else(|_| {
+                            Err(Error::invalid_type(Unexpected::Str(s), &self))
+                        })
+                    }
+                }
+
+                deserializer.$method(PrimitiveVisitor)
+            }
+        }
+    }
+}
+
+impl_deserialize_num!(isize, deserialize_i64);
+impl_deserialize_num!(i8, deserialize_i8);
+impl_deserialize_num!(i16, deserialize_i16);
+impl_deserialize_num!(i32, deserialize_i32);
+impl_deserialize_num!(i64, deserialize_i64);
+impl_deserialize_num!(usize, deserialize_u64);
+impl_deserialize_num!(u8, deserialize_u8);
+impl_deserialize_num!(u16, deserialize_u16);
+impl_deserialize_num!(u32, deserialize_u32);
+impl_deserialize_num!(u64, deserialize_u64);
+impl_deserialize_num!(f32, deserialize_f32);
+impl_deserialize_num!(f64, deserialize_f64);
+
+///////////////////////////////////////////////////////////////////////////////
+
+struct CharVisitor;
+
+impl Visitor for CharVisitor {
+    type Value = char;
+
+    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        formatter.write_str("a character")
+    }
+
+    #[inline]
+    fn visit_char<E>(self, v: char) -> Result<char, E>
+        where E: Error
+    {
+        Ok(v)
+    }
+
+    #[inline]
+    fn visit_str<E>(self, v: &str) -> Result<char, E>
+        where E: Error
+    {
+        let mut iter = v.chars();
+        match (iter.next(), iter.next()) {
+            (Some(c), None) => Ok(c),
+            _ => Err(Error::invalid_value(Unexpected::Str(v), &self)),
+        }
+    }
+}
+
+impl Deserialize for char {
+    #[inline]
+    fn deserialize<D>(deserializer: D) -> Result<char, D::Error>
+        where D: Deserializer
+    {
+        deserializer.deserialize_char(CharVisitor)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#[cfg(any(feature = "std", feature = "collections"))]
+struct StringVisitor;
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl Visitor for StringVisitor {
+    type Value = String;
+
+    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        formatter.write_str("a string")
+    }
+
+    fn visit_str<E>(self, v: &str) -> Result<String, E>
+        where E: Error
+    {
+        Ok(v.to_owned())
+    }
+
+    fn visit_string<E>(self, v: String) -> Result<String, E>
+        where E: Error
+    {
+        Ok(v)
+    }
+
+    fn visit_unit<E>(self) -> Result<String, E>
+        where E: Error
+    {
+        Ok(String::new())
+    }
+
+    fn visit_bytes<E>(self, v: &[u8]) -> Result<String, E>
+        where E: Error
+    {
+        match str::from_utf8(v) {
+            Ok(s) => Ok(s.to_owned()),
+            Err(_) => Err(Error::invalid_value(Unexpected::Bytes(v), &self)),
+        }
+    }
+
+    fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<String, E>
+        where E: Error
+    {
+        match String::from_utf8(v) {
+            Ok(s) => Ok(s),
+            Err(e) => Err(Error::invalid_value(Unexpected::Bytes(&e.into_bytes()), &self)),
+        }
+    }
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl Deserialize for String {
+    fn deserialize<D>(deserializer: D) -> Result<String, D::Error>
+        where D: Deserializer
+    {
+        deserializer.deserialize_string(StringVisitor)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+struct OptionVisitor<T> {
+    marker: PhantomData<T>,
+}
+
+impl<T: Deserialize> Visitor for OptionVisitor<T> {
+    type Value = Option<T>;
+
+    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        formatter.write_str("option")
+    }
+
+    #[inline]
+    fn visit_unit<E>(self) -> Result<Option<T>, E>
+        where E: Error
+    {
+        Ok(None)
+    }
+
+    #[inline]
+    fn visit_none<E>(self) -> Result<Option<T>, E>
+        where E: Error
+    {
+        Ok(None)
+    }
+
+    #[inline]
+    fn visit_some<D>(self, deserializer: D) -> Result<Option<T>, D::Error>
+        where D: Deserializer
+    {
+        Ok(Some(try!(Deserialize::deserialize(deserializer))))
+    }
+}
+
+impl<T> Deserialize for Option<T>
+    where T: Deserialize
+{
+    fn deserialize<D>(deserializer: D) -> Result<Option<T>, D::Error>
+        where D: Deserializer
+    {
+        deserializer.deserialize_option(OptionVisitor { marker: PhantomData })
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// A visitor that produces a `PhantomData`.
+pub struct PhantomDataVisitor<T> {
+    marker: PhantomData<T>,
+}
+
+impl<T> Visitor for PhantomDataVisitor<T> {
+    type Value = PhantomData<T>;
+
+    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        formatter.write_str("unit")
+    }
+
+    #[inline]
+    fn visit_unit<E>(self) -> Result<PhantomData<T>, E>
+        where E: Error
+    {
+        Ok(PhantomData)
+    }
+}
+
+impl<T> Deserialize for PhantomData<T> {
+    fn deserialize<D>(deserializer: D) -> Result<PhantomData<T>, D::Error>
+        where D: Deserializer
+    {
+        let visitor = PhantomDataVisitor { marker: PhantomData };
+        deserializer.deserialize_unit_struct("PhantomData", visitor)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+macro_rules! seq_impl {
+    (
+        $ty:ty,
+        $visitor_ty:ident < $($typaram:ident : $bound1:ident $(+ $bound2:ident)*),* >,
+        $visitor:ident,
+        $ctor:expr,
+        $with_capacity:expr,
+        $insert:expr
+    ) => {
+        /// A visitor that produces a sequence.
+        pub struct $visitor_ty<$($typaram),*> {
+            marker: PhantomData<$ty>,
+        }
+
+        impl<$($typaram),*> $visitor_ty<$($typaram),*>
+            where $($typaram: $bound1 $(+ $bound2)*),*
+        {
+            /// Construct a new sequence visitor.
+            pub fn new() -> Self {
+                $visitor_ty {
+                    marker: PhantomData,
+                }
+            }
+        }
+
+        impl<$($typaram),*> Visitor for $visitor_ty<$($typaram),*>
+            where $($typaram: $bound1 $(+ $bound2)*),*
+        {
+            type Value = $ty;
+
+            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                formatter.write_str("a sequence")
+            }
+
+            #[inline]
+            fn visit_unit<E>(self) -> Result<$ty, E>
+                where E: Error,
+            {
+                Ok($ctor)
+            }
+
+            #[inline]
+            fn visit_seq<V>(self, mut $visitor: V) -> Result<$ty, V::Error>
+                where V: SeqVisitor,
+            {
+                let mut values = $with_capacity;
+
+                while let Some(value) = try!($visitor.visit()) {
+                    $insert(&mut values, value);
+                }
+
+                Ok(values)
+            }
+        }
+
+        impl<$($typaram),*> Deserialize for $ty
+            where $($typaram: $bound1 $(+ $bound2)*),*
+        {
+            fn deserialize<D>(deserializer: D) -> Result<$ty, D::Error>
+                where D: Deserializer,
+            {
+                deserializer.deserialize_seq($visitor_ty::new())
+            }
+        }
+    }
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+seq_impl!(
+    BinaryHeap<T>,
+    BinaryHeapVisitor<T: Deserialize + Ord>,
+    visitor,
+    BinaryHeap::new(),
+    BinaryHeap::with_capacity(cmp::min(visitor.size_hint().0, 4096)),
+    BinaryHeap::push);
+
+#[cfg(any(feature = "std", feature = "collections"))]
+seq_impl!(
+    BTreeSet<T>,
+    BTreeSetVisitor<T: Deserialize + Eq + Ord>,
+    visitor,
+    BTreeSet::new(),
+    BTreeSet::new(),
+    BTreeSet::insert);
+
+#[cfg(any(feature = "std", feature = "collections"))]
+seq_impl!(
+    LinkedList<T>,
+    LinkedListVisitor<T: Deserialize>,
+    visitor,
+    LinkedList::new(),
+    LinkedList::new(),
+    LinkedList::push_back);
+
+#[cfg(feature = "std")]
+seq_impl!(
+    HashSet<T, S>,
+    HashSetVisitor<T: Deserialize + Eq + Hash,
+                   S: BuildHasher + Default>,
+    visitor,
+    HashSet::with_hasher(S::default()),
+    HashSet::with_capacity_and_hasher(cmp::min(visitor.size_hint().0, 4096), S::default()),
+    HashSet::insert);
+
+#[cfg(any(feature = "std", feature = "collections"))]
+seq_impl!(
+    Vec<T>,
+    VecVisitor<T: Deserialize>,
+    visitor,
+    Vec::new(),
+    Vec::with_capacity(cmp::min(visitor.size_hint().0, 4096)),
+    Vec::push);
+
+#[cfg(any(feature = "std", feature = "collections"))]
+seq_impl!(
+    VecDeque<T>,
+    VecDequeVisitor<T: Deserialize>,
+    visitor,
+    VecDeque::new(),
+    VecDeque::with_capacity(cmp::min(visitor.size_hint().0, 4096)),
+    VecDeque::push_back);
+
+///////////////////////////////////////////////////////////////////////////////
+
+struct ArrayVisitor<A> {
+    marker: PhantomData<A>,
+}
+
+impl<A> ArrayVisitor<A> {
+    pub fn new() -> Self {
+        ArrayVisitor { marker: PhantomData }
+    }
+}
+
+impl<T> Visitor for ArrayVisitor<[T; 0]>
+    where T: Deserialize
+{
+    type Value = [T; 0];
+
+    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        formatter.write_str("an empty array")
+    }
+
+    #[inline]
+    fn visit_unit<E>(self) -> Result<[T; 0], E>
+        where E: Error
+    {
+        Ok([])
+    }
+
+    #[inline]
+    fn visit_seq<V>(self, _: V) -> Result<[T; 0], V::Error>
+        where V: SeqVisitor
+    {
+        Ok([])
+    }
+}
+
+impl<T> Deserialize for [T; 0]
+    where T: Deserialize
+{
+    fn deserialize<D>(deserializer: D) -> Result<[T; 0], D::Error>
+        where D: Deserializer
+    {
+        deserializer.deserialize_seq_fixed_size(0, ArrayVisitor::<[T; 0]>::new())
+    }
+}
+
+macro_rules! array_impls {
+    ($($len:expr => ($($n:tt $name:ident)+))+) => {
+        $(
+            impl<T> Visitor for ArrayVisitor<[T; $len]> where T: Deserialize {
+                type Value = [T; $len];
+
+                fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                    formatter.write_str(concat!("an array of length ", $len))
+                }
+
+                #[inline]
+                fn visit_seq<V>(self, mut visitor: V) -> Result<[T; $len], V::Error>
+                    where V: SeqVisitor,
+                {
+                    $(
+                        let $name = match try!(visitor.visit()) {
+                            Some(val) => val,
+                            None => return Err(Error::invalid_length($n, &self)),
+                        };
+                    )+
+
+                    Ok([$($name),+])
+                }
+            }
+
+            impl<T> Deserialize for [T; $len]
+                where T: Deserialize,
+            {
+                fn deserialize<D>(deserializer: D) -> Result<[T; $len], D::Error>
+                    where D: Deserializer,
+                {
+                    deserializer.deserialize_seq_fixed_size($len, ArrayVisitor::<[T; $len]>::new())
+                }
+            }
+        )+
+    }
+}
+
+array_impls! {
+    1 => (0 a)
+    2 => (0 a 1 b)
+    3 => (0 a 1 b 2 c)
+    4 => (0 a 1 b 2 c 3 d)
+    5 => (0 a 1 b 2 c 3 d 4 e)
+    6 => (0 a 1 b 2 c 3 d 4 e 5 f)
+    7 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g)
+    8 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h)
+    9 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i)
+    10 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j)
+    11 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k)
+    12 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l)
+    13 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m)
+    14 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n)
+    15 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o)
+    16 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p)
+    17 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q)
+    18 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r)
+    19 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s)
+    20 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t)
+    21 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u)
+    22 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v)
+    23 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w)
+    24 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x)
+    25 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y)
+    26 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z)
+    27 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa)
+    28 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa 27 ab)
+    29 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa 27 ab 28 ac)
+    30 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa 27 ab 28 ac 29 ad)
+    31 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa 27 ab 28 ac 29 ad 30 ae)
+    32 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa 27 ab 28 ac 29 ad 30 ae 31 af)
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+macro_rules! tuple_impls {
+    ($($len:expr => $visitor:ident => ($($n:tt $name:ident)+))+) => {
+        $(
+            /// Construct a tuple visitor.
+            pub struct $visitor<$($name,)+> {
+                marker: PhantomData<($($name,)+)>,
+            }
+
+            impl<$($name: Deserialize,)+> $visitor<$($name,)+> {
+                /// Construct a `TupleVisitor*<T>`.
+                pub fn new() -> Self {
+                    $visitor { marker: PhantomData }
+                }
+            }
+
+            impl<$($name: Deserialize),+> Visitor for $visitor<$($name,)+> {
+                type Value = ($($name,)+);
+
+                fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                    formatter.write_str(concat!("a tuple of size ", $len))
+                }
+
+                #[inline]
+                #[allow(non_snake_case)]
+                fn visit_seq<V>(self, mut visitor: V) -> Result<($($name,)+), V::Error>
+                    where V: SeqVisitor,
+                {
+                    $(
+                        let $name = match try!(visitor.visit()) {
+                            Some(value) => value,
+                            None => return Err(Error::invalid_length($n, &self)),
+                        };
+                    )+
+
+                    Ok(($($name,)+))
+                }
+            }
+
+            impl<$($name: Deserialize),+> Deserialize for ($($name,)+) {
+                #[inline]
+                fn deserialize<D>(deserializer: D) -> Result<($($name,)+), D::Error>
+                    where D: Deserializer,
+                {
+                    deserializer.deserialize_tuple($len, $visitor::new())
+                }
+            }
+        )+
+    }
+}
+
+tuple_impls! {
+    1 => TupleVisitor1 => (0 T0)
+    2 => TupleVisitor2 => (0 T0 1 T1)
+    3 => TupleVisitor3 => (0 T0 1 T1 2 T2)
+    4 => TupleVisitor4 => (0 T0 1 T1 2 T2 3 T3)
+    5 => TupleVisitor5 => (0 T0 1 T1 2 T2 3 T3 4 T4)
+    6 => TupleVisitor6 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5)
+    7 => TupleVisitor7 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6)
+    8 => TupleVisitor8 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7)
+    9 => TupleVisitor9 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8)
+    10 => TupleVisitor10 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9)
+    11 => TupleVisitor11 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10)
+    12 => TupleVisitor12 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11)
+    13 => TupleVisitor13 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12)
+    14 => TupleVisitor14 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13)
+    15 => TupleVisitor15 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13 14 T14)
+    16 => TupleVisitor16 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13 14 T14 15 T15)
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+macro_rules! map_impl {
+    (
+        $ty:ty,
+        $visitor_ty:ident < $($typaram:ident : $bound1:ident $(+ $bound2:ident)*),* >,
+        $visitor:ident,
+        $ctor:expr,
+        $with_capacity:expr
+    ) => {
+        /// A visitor that produces a map.
+        pub struct $visitor_ty<$($typaram),*> {
+            marker: PhantomData<$ty>,
+        }
+
+        impl<$($typaram),*> $visitor_ty<$($typaram),*>
+            where $($typaram: $bound1 $(+ $bound2)*),*
+        {
+            /// Construct a `MapVisitor*<T>`.
+            pub fn new() -> Self {
+                $visitor_ty {
+                    marker: PhantomData,
+                }
+            }
+        }
+
+        impl<$($typaram),*> Visitor for $visitor_ty<$($typaram),*>
+            where $($typaram: $bound1 $(+ $bound2)*),*
+        {
+            type Value = $ty;
+
+            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                formatter.write_str("a map")
+            }
+
+            #[inline]
+            fn visit_unit<E>(self) -> Result<$ty, E>
+                where E: Error,
+            {
+                Ok($ctor)
+            }
+
+            #[inline]
+            fn visit_map<Visitor>(self, mut $visitor: Visitor) -> Result<$ty, Visitor::Error>
+                where Visitor: MapVisitor,
+            {
+                let mut values = $with_capacity;
+
+                while let Some((key, value)) = try!($visitor.visit()) {
+                    values.insert(key, value);
+                }
+
+                Ok(values)
+            }
+        }
+
+        impl<$($typaram),*> Deserialize for $ty
+            where $($typaram: $bound1 $(+ $bound2)*),*
+        {
+            fn deserialize<D>(deserializer: D) -> Result<$ty, D::Error>
+                where D: Deserializer,
+            {
+                deserializer.deserialize_map($visitor_ty::new())
+            }
+        }
+    }
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+map_impl!(
+    BTreeMap<K, V>,
+    BTreeMapVisitor<K: Deserialize + Ord,
+                    V: Deserialize>,
+    visitor,
+    BTreeMap::new(),
+    BTreeMap::new());
+
+#[cfg(feature = "std")]
+map_impl!(
+    HashMap<K, V, S>,
+    HashMapVisitor<K: Deserialize + Eq + Hash,
+                   V: Deserialize,
+                   S: BuildHasher + Default>,
+    visitor,
+    HashMap::with_hasher(S::default()),
+    HashMap::with_capacity_and_hasher(cmp::min(visitor.size_hint().0, 4096), S::default()));
+
+///////////////////////////////////////////////////////////////////////////////
+
+#[cfg(feature = "std")]
+impl Deserialize for net::IpAddr {
+    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+        where D: Deserializer
+    {
+        let s = try!(String::deserialize(deserializer));
+        match s.parse() {
+            Ok(s) => Ok(s),
+            Err(err) => Err(D::Error::custom(err)),
+        }
+    }
+}
+
+#[cfg(feature = "std")]
+impl Deserialize for net::Ipv4Addr {
+    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+        where D: Deserializer
+    {
+        let s = try!(String::deserialize(deserializer));
+        match s.parse() {
+            Ok(s) => Ok(s),
+            Err(err) => Err(D::Error::custom(err)),
+        }
+    }
+}
+
+#[cfg(feature = "std")]
+impl Deserialize for net::Ipv6Addr {
+    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+        where D: Deserializer
+    {
+        let s = try!(String::deserialize(deserializer));
+        match s.parse() {
+            Ok(s) => Ok(s),
+            Err(err) => Err(D::Error::custom(err)),
+        }
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#[cfg(feature = "std")]
+impl Deserialize for net::SocketAddr {
+    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+        where D: Deserializer
+    {
+        let s = try!(String::deserialize(deserializer));
+        match s.parse() {
+            Ok(s) => Ok(s),
+            Err(err) => Err(D::Error::custom(err)),
+        }
+    }
+}
+
+#[cfg(feature = "std")]
+impl Deserialize for net::SocketAddrV4 {
+    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+        where D: Deserializer
+    {
+        let s = try!(String::deserialize(deserializer));
+        match s.parse() {
+            Ok(s) => Ok(s),
+            Err(err) => Err(D::Error::custom(err)),
+        }
+    }
+}
+
+#[cfg(feature = "std")]
+impl Deserialize for net::SocketAddrV6 {
+    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+        where D: Deserializer
+    {
+        let s = try!(String::deserialize(deserializer));
+        match s.parse() {
+            Ok(s) => Ok(s),
+            Err(err) => Err(D::Error::custom(err)),
+        }
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#[cfg(feature = "std")]
+struct PathBufVisitor;
+
+#[cfg(feature = "std")]
+impl Visitor for PathBufVisitor {
+    type Value = path::PathBuf;
+
+    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        formatter.write_str("path string")
+    }
+
+    fn visit_str<E>(self, v: &str) -> Result<path::PathBuf, E>
+        where E: Error
+    {
+        Ok(From::from(v))
+    }
+
+    fn visit_string<E>(self, v: String) -> Result<path::PathBuf, E>
+        where E: Error
+    {
+        Ok(From::from(v))
+    }
+}
+
+#[cfg(feature = "std")]
+impl Deserialize for path::PathBuf {
+    fn deserialize<D>(deserializer: D) -> Result<path::PathBuf, D::Error>
+        where D: Deserializer
+    {
+        deserializer.deserialize_string(PathBufVisitor)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#[cfg(any(feature = "std", feature = "alloc"))]
+impl<T: Deserialize> Deserialize for Box<T> {
+    fn deserialize<D>(deserializer: D) -> Result<Box<T>, D::Error>
+        where D: Deserializer
+    {
+        let val = try!(Deserialize::deserialize(deserializer));
+        Ok(Box::new(val))
+    }
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<T: Deserialize> Deserialize for Box<[T]> {
+    fn deserialize<D>(deserializer: D) -> Result<Box<[T]>, D::Error>
+        where D: Deserializer
+    {
+        let v: Vec<T> = try!(Deserialize::deserialize(deserializer));
+        Ok(v.into_boxed_slice())
+    }
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl Deserialize for Box<str> {
+    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+        where D: Deserializer
+    {
+        let s = try!(String::deserialize(deserializer));
+        Ok(s.into_boxed_str())
+    }
+}
+
+#[cfg(any(feature = "std", feature = "alloc"))]
+impl<T: Deserialize> Deserialize for Arc<T> {
+    fn deserialize<D>(deserializer: D) -> Result<Arc<T>, D::Error>
+        where D: Deserializer
+    {
+        let val = try!(Deserialize::deserialize(deserializer));
+        Ok(Arc::new(val))
+    }
+}
+
+#[cfg(any(feature = "std", feature = "alloc"))]
+impl<T: Deserialize> Deserialize for Rc<T> {
+    fn deserialize<D>(deserializer: D) -> Result<Rc<T>, D::Error>
+        where D: Deserializer
+    {
+        let val = try!(Deserialize::deserialize(deserializer));
+        Ok(Rc::new(val))
+    }
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<'a, T: ?Sized> Deserialize for Cow<'a, T>
+    where T: ToOwned,
+          T::Owned: Deserialize
+{
+    #[inline]
+    fn deserialize<D>(deserializer: D) -> Result<Cow<'a, T>, D::Error>
+        where D: Deserializer
+    {
+        let val = try!(Deserialize::deserialize(deserializer));
+        Ok(Cow::Owned(val))
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+// This is a cleaned-up version of the impl generated by:
+//
+//     #[derive(Deserialize)]
+//     #[serde(deny_unknown_fields)]
+//     struct Duration {
+//         secs: u64,
+//         nanos: u32,
+//     }
+#[cfg(feature = "std")]
+impl Deserialize for Duration {
+    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+        where D: Deserializer
+    {
+        enum Field {
+            Secs,
+            Nanos,
+        };
+
+        impl Deserialize for Field {
+            fn deserialize<D>(deserializer: D) -> Result<Field, D::Error>
+                where D: Deserializer
+            {
+                struct FieldVisitor;
+
+                impl Visitor for FieldVisitor {
+                    type Value = Field;
+
+                    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                        formatter.write_str("`secs` or `nanos`")
+                    }
+
+                    fn visit_str<E>(self, value: &str) -> Result<Field, E>
+                        where E: Error
+                    {
+                        match value {
+                            "secs" => Ok(Field::Secs),
+                            "nanos" => Ok(Field::Nanos),
+                            _ => Err(Error::unknown_field(value, FIELDS)),
+                        }
+                    }
+
+                    fn visit_bytes<E>(self, value: &[u8]) -> Result<Field, E>
+                        where E: Error
+                    {
+                        match value {
+                            b"secs" => Ok(Field::Secs),
+                            b"nanos" => Ok(Field::Nanos),
+                            _ => {
+                                let value = String::from_utf8_lossy(value);
+                                Err(Error::unknown_field(&value, FIELDS))
+                            }
+                        }
+                    }
+                }
+
+                deserializer.deserialize_struct_field(FieldVisitor)
+            }
+        }
+
+        struct DurationVisitor;
+
+        impl Visitor for DurationVisitor {
+            type Value = Duration;
+
+            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                formatter.write_str("struct Duration")
+            }
+
+            fn visit_seq<V>(self, mut visitor: V) -> Result<Duration, V::Error>
+                where V: SeqVisitor
+            {
+                let secs: u64 = match try!(visitor.visit()) {
+                    Some(value) => value,
+                    None => {
+                        return Err(Error::invalid_length(0, &self));
+                    }
+                };
+                let nanos: u32 = match try!(visitor.visit()) {
+                    Some(value) => value,
+                    None => {
+                        return Err(Error::invalid_length(1, &self));
+                    }
+                };
+                Ok(Duration::new(secs, nanos))
+            }
+
+            fn visit_map<V>(self, mut visitor: V) -> Result<Duration, V::Error>
+                where V: MapVisitor
+            {
+                let mut secs: Option<u64> = None;
+                let mut nanos: Option<u32> = None;
+                while let Some(key) = try!(visitor.visit_key::<Field>()) {
+                    match key {
+                        Field::Secs => {
+                            if secs.is_some() {
+                                return Err(<V::Error as Error>::duplicate_field("secs"));
+                            }
+                            secs = Some(try!(visitor.visit_value()));
+                        }
+                        Field::Nanos => {
+                            if nanos.is_some() {
+                                return Err(<V::Error as Error>::duplicate_field("nanos"));
+                            }
+                            nanos = Some(try!(visitor.visit_value()));
+                        }
+                    }
+                }
+                let secs = match secs {
+                    Some(secs) => secs,
+                    None => return Err(<V::Error as Error>::missing_field("secs")),
+                };
+                let nanos = match nanos {
+                    Some(nanos) => nanos,
+                    None => return Err(<V::Error as Error>::missing_field("nanos")),
+                };
+                Ok(Duration::new(secs, nanos))
+            }
+        }
+
+        const FIELDS: &'static [&'static str] = &["secs", "nanos"];
+        deserializer.deserialize_struct("Duration", FIELDS, DurationVisitor)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#[cfg(feature = "unstable")]
+#[allow(deprecated)] // num::Zero is deprecated but there is no replacement
+impl<T> Deserialize for NonZero<T>
+    where T: Deserialize + PartialEq + Zeroable + Zero
+{
+    fn deserialize<D>(deserializer: D) -> Result<NonZero<T>, D::Error>
+        where D: Deserializer
+    {
+        let value = try!(Deserialize::deserialize(deserializer));
+        if value == Zero::zero() {
+            return Err(Error::custom("expected a non-zero value"));
+        }
+        unsafe { Ok(NonZero::new(value)) }
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+
+impl<T, E> Deserialize for Result<T, E>
+    where T: Deserialize,
+          E: Deserialize
+{
+    fn deserialize<D>(deserializer: D) -> Result<Result<T, E>, D::Error>
+        where D: Deserializer
+    {
+        enum Field {
+            Ok,
+            Err,
+        }
+
+        impl Deserialize for Field {
+            #[inline]
+            fn deserialize<D>(deserializer: D) -> Result<Field, D::Error>
+                where D: Deserializer
+            {
+                struct FieldVisitor;
+
+                impl Visitor for FieldVisitor {
+                    type Value = Field;
+
+                    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                        formatter.write_str("`Ok` or `Err`")
+                    }
+
+                    fn visit_u32<E>(self, value: u32) -> Result<Field, E>
+                        where E: Error
+                    {
+                        match value {
+                            0 => Ok(Field::Ok),
+                            1 => Ok(Field::Err),
+                            _ => {
+                                Err(Error::invalid_value(Unexpected::Unsigned(value as u64), &self))
+                            }
+                        }
+                    }
+
+                    fn visit_str<E>(self, value: &str) -> Result<Field, E>
+                        where E: Error
+                    {
+                        match value {
+                            "Ok" => Ok(Field::Ok),
+                            "Err" => Ok(Field::Err),
+                            _ => Err(Error::unknown_variant(value, VARIANTS)),
+                        }
+                    }
+
+                    fn visit_bytes<E>(self, value: &[u8]) -> Result<Field, E>
+                        where E: Error
+                    {
+                        match value {
+                            b"Ok" => Ok(Field::Ok),
+                            b"Err" => Ok(Field::Err),
+                            _ => {
+                                match str::from_utf8(value) {
+                                    Ok(value) => Err(Error::unknown_variant(value, VARIANTS)),
+                                    Err(_) => {
+                                        Err(Error::invalid_value(Unexpected::Bytes(value), &self))
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+
+                deserializer.deserialize(FieldVisitor)
+            }
+        }
+
+        struct ResultVisitor<T, E>(PhantomData<Result<T, E>>);
+
+        impl<T, E> Visitor for ResultVisitor<T, E>
+            where T: Deserialize,
+                  E: Deserialize
+        {
+            type Value = Result<T, E>;
+
+            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                formatter.write_str("enum Result")
+            }
+
+            fn visit_enum<V>(self, visitor: V) -> Result<Result<T, E>, V::Error>
+                where V: EnumVisitor
+            {
+                match try!(visitor.visit_variant()) {
+                    (Field::Ok, variant) => variant.visit_newtype().map(Ok),
+                    (Field::Err, variant) => variant.visit_newtype().map(Err),
+                }
+            }
+        }
+
+        const VARIANTS: &'static [&'static str] = &["Ok", "Err"];
+
+        deserializer.deserialize_enum("Result", VARIANTS, ResultVisitor(PhantomData))
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// A target for deserializers that want to ignore data. Implements
+/// Deserialize and silently eats data given to it.
+pub struct IgnoredAny;
+
+impl Deserialize for IgnoredAny {
+    #[inline]
+    fn deserialize<D>(deserializer: D) -> Result<IgnoredAny, D::Error>
+        where D: Deserializer
+    {
+        struct IgnoredAnyVisitor;
+
+        impl Visitor for IgnoredAnyVisitor {
+            type Value = IgnoredAny;
+
+            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                formatter.write_str("anything at all")
+            }
+
+            #[inline]
+            fn visit_bool<E>(self, _: bool) -> Result<IgnoredAny, E> {
+                Ok(IgnoredAny)
+            }
+
+            #[inline]
+            fn visit_i64<E>(self, _: i64) -> Result<IgnoredAny, E> {
+                Ok(IgnoredAny)
+            }
+
+            #[inline]
+            fn visit_u64<E>(self, _: u64) -> Result<IgnoredAny, E> {
+                Ok(IgnoredAny)
+            }
+
+            #[inline]
+            fn visit_f64<E>(self, _: f64) -> Result<IgnoredAny, E> {
+                Ok(IgnoredAny)
+            }
+
+            #[inline]
+            fn visit_str<E>(self, _: &str) -> Result<IgnoredAny, E>
+                where E: Error
+            {
+                Ok(IgnoredAny)
+            }
+
+            #[inline]
+            fn visit_none<E>(self) -> Result<IgnoredAny, E> {
+                Ok(IgnoredAny)
+            }
+
+            #[inline]
+            fn visit_some<D>(self, _: D) -> Result<IgnoredAny, D::Error>
+                where D: Deserializer
+            {
+                Ok(IgnoredAny)
+            }
+
+            #[inline]
+            fn visit_newtype_struct<D>(self, _: D) -> Result<IgnoredAny, D::Error>
+                where D: Deserializer
+            {
+                Ok(IgnoredAny)
+            }
+
+            #[inline]
+            fn visit_unit<E>(self) -> Result<IgnoredAny, E> {
+                Ok(IgnoredAny)
+            }
+
+            #[inline]
+            fn visit_seq<V>(self, mut visitor: V) -> Result<IgnoredAny, V::Error>
+                where V: SeqVisitor
+            {
+                while let Some(_) = try!(visitor.visit::<IgnoredAny>()) {
+                    // Gobble
+                }
+                Ok(IgnoredAny)
+            }
+
+            #[inline]
+            fn visit_map<V>(self, mut visitor: V) -> Result<IgnoredAny, V::Error>
+                where V: MapVisitor
+            {
+                while let Some((_, _)) = try!(visitor.visit::<IgnoredAny, IgnoredAny>()) {
+                    // Gobble
+                }
+                Ok(IgnoredAny)
+            }
+
+            #[inline]
+            fn visit_bytes<E>(self, _: &[u8]) -> Result<IgnoredAny, E>
+                where E: Error
+            {
+                Ok(IgnoredAny)
+            }
+        }
+
+        // TODO maybe not necessary with impl specialization
+        deserializer.deserialize_ignored_any(IgnoredAnyVisitor)
+    }
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde-0.9.9/src/de/mod.rs
@@ -0,0 +1,1611 @@
+//! Generic data structure deserialization framework.
+//!
+//! The two most important traits in this module are `Deserialize` and
+//! `Deserializer`.
+//!
+//!  - **A type that implements `Deserialize` is a data structure** that can be
+//!    deserialized from any data format supported by Serde, and conversely
+//!  - **A type that implements `Deserializer` is a data format** that can
+//!    deserialize any data structure supported by Serde.
+//!
+//! # The Deserialize trait
+//!
+//! Serde provides `Deserialize` implementations for many Rust primitive and
+//! standard library types. The complete list is below. All of these can be
+//! deserialized using Serde out of the box.
+//!
+//! Additionally, Serde provides a procedural macro called `serde_derive` to
+//! automatically generate `Deserialize` implementations for structs and enums
+//! in your program. See the [codegen section of the manual][codegen] for how to
+//! use this.
+//!
+//! In rare cases it may be necessary to implement `Deserialize` manually for
+//! some type in your program. See the [Implementing
+//! `Deserialize`][impl-deserialize] section of the manual for more about this.
+//!
+//! Third-party crates may provide `Deserialize` implementations for types that
+//! they expose. For example the `linked-hash-map` crate provides a
+//! `LinkedHashMap<K, V>` type that is deserializable by Serde because the crate
+//! provides an implementation of `Deserialize` for it.
+//!
+//! # The Deserializer trait
+//!
+//! `Deserializer` implementations are provided by third-party crates, for
+//! example [`serde_json`][serde_json], [`serde_yaml`][serde_yaml] and
+//! [`bincode`][bincode].
+//!
+//! A partial list of well-maintained formats is given on the [Serde
+//! website][data-formats].
+//!
+//! # Implementations of Deserialize provided by Serde
+//!
+//! This is a slightly different set of types than what is supported for
+//! serialization. Some types can be serialized by Serde but not deserialized.
+//! One example is `&str`.
+//!
+//!  - **Primitive types**:
+//!    - bool
+//!    - isize, i8, i16, i32, i64
+//!    - usize, u8, u16, u32, u64
+//!    - f32, f64
+//!    - char
+//!  - **Compound types**:
+//!    - [T; 0] through [T; 32]
+//!    - tuples up to size 16
+//!  - **Common standard library types**:
+//!    - String
+//!    - Option\<T\>
+//!    - Result\<T, E\>
+//!    - PhantomData\<T\>
+//!  - **Wrapper types**:
+//!    - Box\<T\>
+//!    - Box\<[T]\>
+//!    - Box\<str\>
+//!    - Rc\<T\>
+//!    - Arc\<T\>
+//!    - Cow\<'a, T\>
+//!  - **Collection types**:
+//!    - BTreeMap\<K, V\>
+//!    - BTreeSet\<T\>
+//!    - BinaryHeap\<T\>
+//!    - HashMap\<K, V, H\>
+//!    - HashSet\<T, H\>
+//!    - LinkedList\<T\>
+//!    - VecDeque\<T\>
+//!    - Vec\<T\>
+//!    - EnumSet\<T\> (unstable)
+//!  - **Miscellaneous standard library types**:
+//!    - Duration
+//!    - Path
+//!    - PathBuf
+//!    - NonZero\<T\> (unstable)
+//!  - **Net types**:
+//!    - IpAddr
+//!    - Ipv4Addr
+//!    - Ipv6Addr
+//!    - SocketAddr
+//!    - SocketAddrV4
+//!    - SocketAddrV6
+//!
+//! [codegen]: https://serde.rs/codegen.html
+//! [impl-deserialize]: https://serde.rs/impl-deserialize.html
+//! [serde_json]: https://github.com/serde-rs/json
+//! [serde_yaml]: https://github.com/dtolnay/serde-yaml
+//! [bincode]: https://github.com/TyOverby/bincode
+//! [data-formats]: https://serde.rs/#data-formats
+
+#[cfg(feature = "std")]
+use std::error;
+#[cfg(not(feature = "std"))]
+use error;
+
+#[cfg(all(not(feature = "std"), feature = "collections"))]
+use collections::{String, Vec};
+
+use core::fmt::{self, Display};
+use core::marker::PhantomData;
+
+///////////////////////////////////////////////////////////////////////////////
+
+#[doc(hidden)]
+pub mod impls;
+pub mod value;
+mod from_primitive;
+
+// Helpers used by generated code. Not public API.
+#[doc(hidden)]
+pub mod private;
+#[cfg(any(feature = "std", feature = "collections"))]
+mod content;
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// The `Error` trait allows `Deserialize` implementations to create descriptive
+/// error messages belonging to the `Deserializer` against which they are
+/// currently running.
+///
+/// Every `Deserializer` declares an `Error` type that encompasses both
+/// general-purpose deserialization errors as well as errors specific to the
+/// particular deserialization format. For example the `Error` type of
+/// `serde_json` can represent errors like an invalid JSON escape sequence or an
+/// unterminated string literal, in addition to the error cases that are part of
+/// this trait.
+///
+/// Most deserializers should only need to provide the `Error::custom` method
+/// and inherit the default behavior for the other methods.
+pub trait Error: Sized + error::Error {
+    /// Raised when there is general error when deserializing a type.
+    ///
+    /// The message should not be capitalized and should not end with a period.
+    ///
+    /// ```rust
+    /// # use serde::de::{Deserialize, Deserializer, Error};
+    /// # use std::str::FromStr;
+    /// # #[allow(dead_code)]
+    /// # struct IpAddr;
+    /// # impl FromStr for IpAddr {
+    /// #     type Err = String;
+    /// #     fn from_str(_: &str) -> Result<Self, String> { unimplemented!() }
+    /// # }
+    /// impl Deserialize for IpAddr {
+    ///     fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+    ///         where D: Deserializer
+    ///     {
+    ///         let s = try!(String::deserialize(deserializer));
+    ///         s.parse().map_err(Error::custom)
+    ///     }
+    /// }
+    /// ```
+    fn custom<T: Display>(msg: T) -> Self;
+
+    /// Raised when a `Deserialize` receives a type different from what it was
+    /// expecting.
+    ///
+    /// The `unexp` argument provides information about what type was received.
+    /// This is the type that was present in the input file or other source data
+    /// of the Deserializer.
+    ///
+    /// The `exp` argument provides information about what type was being
+    /// expected. This is the type that is written in the program.
+    ///
+    /// For example if we try to deserialize a String out of a JSON file
+    /// containing an integer, the unexpected type is the integer and the
+    /// expected type is the string.
+    fn invalid_type(unexp: Unexpected, exp: &Expected) -> Self {
+        struct InvalidType<'a> {
+            unexp: Unexpected<'a>,
+            exp: &'a Expected,
+        }
+        impl<'a> Display for InvalidType<'a> {
+            fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                write!(formatter, "invalid type: {}, expected {}", self.unexp, self.exp)
+            }
+        }
+        Error::custom(InvalidType {
+            unexp: unexp,
+            exp: exp,
+        })
+    }
+
+    /// Raised when a `Deserialize` receives a value of the right type but that
+    /// is wrong for some other reason.
+    ///
+    /// The `unexp` argument provides information about what value was received.
+    /// This is the value that was present in the input file or other source
+    /// data of the Deserializer.
+    ///
+    /// The `exp` argument provides information about what value was being
+    /// expected. This is the type that is written in the program.
+    ///
+    /// For example if we try to deserialize a String out of some binary data
+    /// that is not valid UTF-8, the unexpected value is the bytes and the
+    /// expected value is a string.
+    fn invalid_value(unexp: Unexpected, exp: &Expected) -> Self {
+        struct InvalidValue<'a> {
+            unexp: Unexpected<'a>,
+            exp: &'a Expected,
+        }
+        impl<'a> Display for InvalidValue<'a> {
+            fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                write!(formatter, "invalid value: {}, expected {}", self.unexp, self.exp)
+            }
+        }
+        Error::custom(InvalidValue {
+            unexp: unexp,
+            exp: exp,
+        })
+    }
+
+    /// Raised when deserializing a sequence or map and the input data contains
+    /// too many or too few elements.
+    ///
+    /// The `len` argument is the number of elements encountered. The sequence
+    /// or map may have expected more arguments or fewer arguments.
+    ///
+    /// The `exp` argument provides information about what data was being
+    /// expected. For example `exp` might say that a tuple of size 6 was
+    /// expected.
+    fn invalid_length(len: usize, exp: &Expected) -> Self {
+        struct InvalidLength<'a> {
+            len: usize,
+            exp: &'a Expected,
+        }
+        impl<'a> Display for InvalidLength<'a> {
+            fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                write!(formatter, "invalid length {}, expected {}", self.len, self.exp)
+            }
+        }
+        Error::custom(InvalidLength {
+            len: len,
+            exp: exp,
+        })
+    }
+
+    /// Raised when a `Deserialize` enum type received a variant with an
+    /// unrecognized name.
+    fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self {
+        struct UnknownVariant<'a> {
+            variant: &'a str,
+            expected: &'static [&'static str],
+        }
+        impl<'a> Display for UnknownVariant<'a> {
+            fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                if self.expected.is_empty() {
+                    write!(formatter,
+                           "unknown variant `{}`, there are no variants",
+                           self.variant)
+                } else {
+                    write!(formatter,
+                           "unknown variant `{}`, expected {}",
+                           self.variant,
+                           OneOf { names: self.expected })
+                }
+            }
+        }
+        Error::custom(UnknownVariant {
+            variant: variant,
+            expected: expected,
+        })
+    }
+
+    /// Raised when a `Deserialize` struct type received a field with an
+    /// unrecognized name.
+    fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self {
+        struct UnknownField<'a> {
+            field: &'a str,
+            expected: &'static [&'static str],
+        }
+        impl<'a> Display for UnknownField<'a> {
+            fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                if self.expected.is_empty() {
+                    write!(formatter,
+                           "unknown field `{}`, there are no fields",
+                           self.field)
+                } else {
+                    write!(formatter,
+                           "unknown field `{}`, expected {}",
+                           self.field,
+                           OneOf { names: self.expected })
+                }
+            }
+        }
+        Error::custom(UnknownField {
+            field: field,
+            expected: expected,
+        })
+    }
+
+    /// Raised when a `Deserialize` struct type expected to receive a required
+    /// field with a particular name but that field was not present in the
+    /// input.
+    fn missing_field(field: &'static str) -> Self {
+        struct MissingField {
+            field: &'static str,
+        }
+        impl Display for MissingField {
+            fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                write!(formatter, "missing field `{}`", self.field)
+            }
+        }
+        Error::custom(MissingField { field: field })
+    }
+
+    /// Raised when a `Deserialize` struct type received more than one of the
+    /// same field.
+    fn duplicate_field(field: &'static str) -> Self {
+        struct DuplicateField {
+            field: &'static str,
+        }
+        impl Display for DuplicateField {
+            fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                write!(formatter, "duplicate field `{}`", self.field)
+            }
+        }
+        Error::custom(DuplicateField { field: field })
+    }
+}
+
+/// `Unexpected` represents an unexpected invocation of any one of the `Visitor`
+/// trait methods.
+///
+/// This is used as an argument to the `invalid_type`, `invalid_value`, and
+/// `invalid_length` methods of the `Error` trait to build error messages.
+///
+/// ```rust
+/// # use serde::de::{Error, Unexpected, Visitor};
+/// # use std::fmt;
+/// # #[allow(dead_code)]
+/// # struct Example;
+/// # impl Visitor for Example {
+/// # type Value = ();
+/// fn visit_bool<E>(self, v: bool) -> Result<Self::Value, E>
+///     where E: Error
+/// {
+///     Err(Error::invalid_type(Unexpected::Bool(v), &self))
+/// }
+/// # fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+/// #     write!(formatter, "definitely not a boolean")
+/// # }
+/// # }
+/// ```
+#[derive(Clone, PartialEq, Debug)]
+pub enum Unexpected<'a> {
+    /// The input contained a boolean value that was not expected.
+    Bool(bool),
+
+    /// The input contained an unsigned integer `u8`, `u16`, `u32` or `u64` that
+    /// was not expected.
+    Unsigned(u64),
+
+    /// The input contained a signed integer `i8`, `i16`, `i32` or `i64` that
+    /// was not expected.
+    Signed(i64),
+
+    /// The input contained a floating point `f32` or `f64` that was not
+    /// expected.
+    Float(f64),
+
+    /// The input contained a `char` that was not expected.
+    Char(char),
+
+    /// The input contained a `&str` or `String` that was not expected.
+    Str(&'a str),
+
+    /// The input contained a `&[u8]` or `Vec<u8>` that was not expected.
+    Bytes(&'a [u8]),
+
+    /// The input contained a unit `()` that was not expected.
+    Unit,
+
+    /// The input contained an `Option<T>` that was not expected.
+    Option,
+
+    /// The input contained a newtype struct that was not expected.
+    NewtypeStruct,
+
+    /// The input contained a sequence that was not expected.
+    Seq,
+
+    /// The input contained a map that was not expected.
+    Map,
+
+    /// The input contained an enum that was not expected.
+    Enum,
+
+    /// The input contained a unit variant that was not expected.
+    UnitVariant,
+
+    /// The input contained a newtype variant that was not expected.
+    NewtypeVariant,
+
+    /// The input contained a tuple variant that was not expected.
+    TupleVariant,
+
+    /// The input contained a struct variant that was not expected.
+    StructVariant,
+
+    /// A message stating what uncategorized thing the input contained that was
+    /// not expected.
+    ///
+    /// The message should be a noun or noun phrase, not capitalized and without
+    /// a period. An example message is "unoriginal superhero".
+    Other(&'a str),
+}
+
+impl<'a> fmt::Display for Unexpected<'a> {
+    fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+        use self::Unexpected::*;
+        match *self {
+            Bool(b) => write!(formatter, "boolean `{}`", b),
+            Unsigned(i) => write!(formatter, "integer `{}`", i),
+            Signed(i) => write!(formatter, "integer `{}`", i),
+            Float(f) => write!(formatter, "floating point `{}`", f),
+            Char(c) => write!(formatter, "character `{}`", c),
+            Str(s) => write!(formatter, "string {:?}", s),
+            Bytes(_) => write!(formatter, "byte array"),
+            Unit => write!(formatter, "unit value"),
+            Option => write!(formatter, "Option value"),
+            NewtypeStruct => write!(formatter, "newtype struct"),
+            Seq => write!(formatter, "sequence"),
+            Map => write!(formatter, "map"),
+            Enum => write!(formatter, "enum"),
+            UnitVariant => write!(formatter, "unit variant"),
+            NewtypeVariant => write!(formatter, "newtype variant"),
+            TupleVariant => write!(formatter, "tuple variant"),
+            StructVariant => write!(formatter, "struct variant"),
+            Other(other) => formatter.write_str(other),
+        }
+    }
+}
+
+/// `Expected` represents an explanation of what data a `Visitor` was expecting
+/// to receive.
+///
+/// This is used as an argument to the `invalid_type`, `invalid_value`, and
+/// `invalid_length` methods of the `Error` trait to build error messages. The
+/// message should be a noun or noun phrase that completes the sentence "This
+/// Visitor expects to receive ...", for example the message could be "an
+/// integer between 0 and 64". The message should not be capitalized and should
+/// not end with a period.
+///
+/// Within the context of a `Visitor` implementation, the `Visitor` itself
+/// (`&self`) is an implementation of this trait.
+///
+/// ```rust
+/// # use serde::de::{Error, Unexpected, Visitor};
+/// # use std::fmt;
+/// # #[allow(dead_code)]
+/// # struct Example;
+/// # impl Visitor for Example {
+/// # type Value = ();
+/// fn visit_bool<E>(self, v: bool) -> Result<Self::Value, E>
+///     where E: Error
+/// {
+///     Err(Error::invalid_type(Unexpected::Bool(v), &self))
+/// }
+/// # fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+/// #     write!(formatter, "definitely not a boolean")
+/// # }
+/// # }
+/// ```
+///
+/// Outside of a `Visitor`, `&"..."` can be used.
+///
+/// ```rust
+/// # use serde::de::{Error, Unexpected};
+/// # #[allow(dead_code)]
+/// # fn example<E: Error>() -> Result<(), E> {
+/// # let v = true;
+/// return Err(Error::invalid_type(Unexpected::Bool(v), &"a negative integer"));
+/// # }
+/// ```
+pub trait Expected {
+    /// Format an explanation of what data was being expected. Same signature as
+    /// the `Display` and `Debug` traits.
+    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result;
+}
+
+impl<T> Expected for T
+    where T: Visitor
+{
+    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        self.expecting(formatter)
+    }
+}
+
+impl<'a> Expected for &'a str {
+    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        formatter.write_str(self)
+    }
+}
+
+impl<'a> Display for Expected + 'a {
+    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        Expected::fmt(self, formatter)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// A **data structure** that can be deserialized from any data format supported
+/// by Serde.
+///
+/// Serde provides `Deserialize` implementations for many Rust primitive and
+/// standard library types. The complete list is [here][de]. All of these can
+/// be deserialized using Serde out of the box.
+///
+/// Additionally, Serde provides a procedural macro called `serde_derive` to
+/// automatically generate `Deserialize` implementations for structs and enums
+/// in your program. See the [codegen section of the manual][codegen] for how to
+/// use this.
+///
+/// In rare cases it may be necessary to implement `Deserialize` manually for
+/// some type in your program. See the [Implementing
+/// `Deserialize`][impl-deserialize] section of the manual for more about this.
+///
+/// Third-party crates may provide `Deserialize` implementations for types that
+/// they expose. For example the `linked-hash-map` crate provides a
+/// `LinkedHashMap<K, V>` type that is deserializable by Serde because the crate
+/// provides an implementation of `Deserialize` for it.
+///
+/// [de]: https://docs.serde.rs/serde/de/index.html
+/// [codegen]: https://serde.rs/codegen.html
+/// [impl-deserialize]: https://serde.rs/impl-deserialize.html
+pub trait Deserialize: Sized {
+    /// Deserialize this value from the given Serde deserializer.
+    ///
+    /// See the [Implementing `Deserialize`][impl-deserialize] section of the
+    /// manual for more information about how to implement this method.
+    ///
+    /// [impl-deserialize]: https://serde.rs/impl-deserialize.html
+    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer;
+}
+
+/// `DeserializeSeed` is the stateful form of the `Deserialize` trait. If you
+/// ever find yourself looking for a way to pass data into a `Deserialize` impl,
+/// this trait is the way to do it.
+///
+/// As one example of stateful deserialization consider deserializing a JSON
+/// array into an existing buffer. Using the `Deserialize` trait we could
+/// deserialize a JSON array into a `Vec<T>` but it would be a freshly allocated
+/// `Vec<T>`; there is no way for `Deserialize` to reuse a previously allocated
+/// buffer. Using `DeserializeSeed` instead makes this possible as in the
+/// example code below.
+///
+/// The canonical API for stateless deserialization looks like this:
+///
+/// ```rust
+/// # use serde::Deserialize;
+/// # #[allow(dead_code)]
+/// # enum Error {}
+/// # #[allow(dead_code)]
+/// fn func<T: Deserialize>() -> Result<T, Error>
+/// # { unimplemented!() }
+/// ```
+///
+/// Adjusting an API like this to support stateful deserialization is a matter
+/// of accepting a seed as input:
+///
+/// ```rust
+/// # use serde::de::DeserializeSeed;
+/// # #[allow(dead_code)]
+/// # enum Error {}
+/// # #[allow(dead_code)]
+/// fn func_seed<T: DeserializeSeed>(seed: T) -> Result<T::Value, Error>
+/// # {
+/// #     let _ = seed;
+/// #     unimplemented!()
+/// # }
+/// ```
+///
+/// In practice the majority of deserialization is stateless. An API expecting a
+/// seed can be appeased by passing `std::marker::PhantomData` as a seed in the
+/// case of stateless deserialization.
+///
+/// # Example
+///
+/// Suppose we have JSON that looks like `[[1, 2], [3, 4, 5], [6]]` and we need
+/// to deserialize it into a flat representation like `vec![1, 2, 3, 4, 5, 6]`.
+/// Allocating a brand new `Vec<T>` for each subarray would be slow. Instead we
+/// would like to allocate a single `Vec<T>` and then deserialize each subarray
+/// into it. This requires stateful deserialization using the `DeserializeSeed`
+/// trait.
+///
+/// ```rust
+/// # use serde::de::{Deserialize, DeserializeSeed, Deserializer, Visitor, SeqVisitor};
+/// # use std::fmt;
+/// # use std::marker::PhantomData;
+/// #
+/// // A DeserializeSeed implementation that uses stateful deserialization to
+/// // append array elements onto the end of an existing vector. The preexisting
+/// // state ("seed") in this case is the Vec<T>. The `deserialize` method of
+/// // `ExtendVec` will be traversing the inner arrays of the JSON input and
+/// // appending each integer into the existing Vec.
+/// struct ExtendVec<'a, T: 'a>(&'a mut Vec<T>);
+///
+/// impl<'a, T> DeserializeSeed for ExtendVec<'a, T>
+///     where T: Deserialize
+/// {
+///     // The return type of the `deserialize` method. This implementation
+///     // appends onto an existing vector but does not create any new data
+///     // structure, so the return type is ().
+///     type Value = ();
+///
+///     fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
+///         where D: Deserializer
+///     {
+///         // Visitor implementation that will walk an inner array of the JSON
+///         // input.
+///         struct ExtendVecVisitor<'a, T: 'a>(&'a mut Vec<T>);
+///
+///         impl<'a, T> Visitor for ExtendVecVisitor<'a, T>
+///             where T: Deserialize
+///         {
+///             type Value = ();
+///
+///             fn visit_seq<V>(self, mut visitor: V) -> Result<(), V::Error>
+///                 where V: SeqVisitor
+///             {
+///                 // Visit each element in the inner array and push it onto
+///                 // the existing vector.
+///                 while let Some(elem) = visitor.visit()? {
+///                     self.0.push(elem);
+///                 }
+///                 Ok(())
+///             }
+/// #
+/// #           fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+/// #               write!(formatter, "an array of integers")
+/// #           }
+///         }
+///
+///         deserializer.deserialize_seq(ExtendVecVisitor(self.0))
+///     }
+/// }
+///
+/// // Visitor implementation that will walk the outer array of the JSON input.
+/// struct FlattenedVecVisitor<T>(PhantomData<T>);
+///
+/// impl<T> Visitor for FlattenedVecVisitor<T>
+///     where T: Deserialize
+/// {
+///     // This Visitor constructs a single Vec<T> to hold the flattened
+///     // contents of the inner arrays.
+///     type Value = Vec<T>;
+///
+///     fn visit_seq<V>(self, mut visitor: V) -> Result<Vec<T>, V::Error>
+///         where V: SeqVisitor
+///     {
+///         // Create a single Vec to hold the flattened contents.
+///         let mut vec = Vec::new();
+///
+///         // Each iteration through this loop is one inner array.
+///         while let Some(()) = visitor.visit_seed(ExtendVec(&mut vec))? {
+///             // Nothing to do; inner array has been appended into `vec`.
+///         }
+///
+///         // Return the finished vec.
+///         Ok(vec)
+///     }
+/// #
+/// #   fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+/// #       write!(formatter, "an array of arrays")
+/// #   }
+/// }
+///
+/// # #[allow(dead_code)]
+/// # fn example<D: Deserializer>(deserializer: D) -> Result<(), D::Error> {
+/// let visitor = FlattenedVecVisitor(PhantomData);
+/// let flattened: Vec<u64> = deserializer.deserialize_seq(visitor)?;
+/// # let _ = flattened;
+/// # Ok(()) }
+/// ```
+pub trait DeserializeSeed: Sized {
+    /// The type produced by using this seed.
+    type Value;
+
+    /// Equivalent to the more common `Deserialize::deserialize` method, except
+    /// with some initial piece of data (the seed) passed in.
+    fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error> where D: Deserializer;
+}
+
+impl<T> DeserializeSeed for PhantomData<T>
+    where T: Deserialize
+{
+    type Value = T;
+
+    #[inline]
+    fn deserialize<D>(self, deserializer: D) -> Result<T, D::Error>
+        where D: Deserializer
+    {
+        T::deserialize(deserializer)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// A **data format** that can deserialize any data structure supported by
+/// Serde.
+///
+/// The role of this trait is to define the deserialization half of the Serde
+/// data model, which is a way to categorize every Rust data type into one of 28
+/// possible types. Each method of the `Serializer` trait corresponds to one of
+/// the types of the data model.
+///
+/// Implementations of `Deserialize` map themselves into this data model by
+/// passing to the `Deserializer` a `Visitor` implementation that can receive
+/// these various types.
+///
+/// The types that make up the Serde data model are:
+///
+///  - 12 primitive types:
+///    - bool
+///    - i8, i16, i32, i64
+///    - u8, u16, u32, u64
+///    - f32, f64
+///    - char
+///  - string
+///  - byte array - [u8]
+///  - option
+///    - either none or some value
+///  - unit
+///    - unit is the type of () in Rust
+///  - unit_struct
+///    - for example `struct Unit` or `PhantomData<T>`
+///  - unit_variant
+///    - the `E::A` and `E::B` in `enum E { A, B }`
+///  - newtype_struct
+///    - for example `struct Millimeters(u8)`
+///  - newtype_variant
+///    - the `E::N` in `enum E { N(u8) }`
+///  - seq
+///    - a dynamically sized sequence of values, for example `Vec<T>` or
+///      `HashSet<T>`
+///  - seq_fixed_size
+///    - a statically sized sequence of values for which the size will be known
+///      at deserialization time without looking at the serialized data, for
+///      example `[u64; 10]`
+///  - tuple
+///    - for example `(u8,)` or `(String, u64, Vec<T>)`
+///  - tuple_struct
+///    - for example `struct Rgb(u8, u8, u8)`
+///  - tuple_variant
+///    - the `E::T` in `enum E { T(u8, u8) }`
+///  - map
+///    - for example `BTreeMap<K, V>`
+///  - struct
+///    - a key-value pairing in which the keys will be known at deserialization
+///      time without looking at the serialized data, for example `struct S { r:
+///      u8, g: u8, b: u8 }`
+///  - struct_variant
+///    - the `E::S` in `enum E { S { r: u8, g: u8, b: u8 } }`
+///
+/// The `Deserializer` trait supports two entry point styles which enables
+/// different kinds of deserialization.
+///
+/// 1. The `deserialize` method. Self-describing data formats like JSON are able
+///    to look at the serialized data and tell what it represents. For example
+///    the JSON deserializer may see an opening curly brace (`{`) and know that
+///    it is seeing a map. If the data format supports
+///    `Deserializer::deserialize`, it will drive the Visitor using whatever
+///    type it sees in the input. JSON uses this approach when deserializing
+///    `serde_json::Value` which is an enum that can represent any JSON
+///    document. Without knowing what is in a JSON document, we can deserialize
+///    it to `serde_json::Value` by going through `Deserializer::deserialize`.
+///
+/// 2. The various `deserialize_*` methods. Non-self-describing formats like
+///    Bincode need to be told what is in the input in order to deserialize it.
+///    The `deserialize_*` methods are hints to the deserializer for how to
+///    interpret the next piece of input. Non-self-describing formats are not
+///    able to deserialize something like `serde_json::Value` which relies on
+///    `Deserializer::deserialize`.
+///
+/// When implementing `Deserialize`, you should avoid relying on
+/// `Deserializer::deserialize` unless you need to be told by the Deserializer
+/// what type is in the input. Know that relying on `Deserializer::deserialize`
+/// means your data type will be able to deserialize from self-describing
+/// formats only, ruling out Bincode and many others.
+pub trait Deserializer: Sized {
+    /// The error type that can be returned if some error occurs during
+    /// deserialization.
+    type Error: Error;
+
+    /// Require the `Deserializer` to figure out how to drive the visitor based
+    /// on what data type is in the input.
+    ///
+    /// When implementing `Deserialize`, you should avoid relying on
+    /// `Deserializer::deserialize` unless you need to be told by the
+    /// Deserializer what type is in the input. Know that relying on
+    /// `Deserializer::deserialize` means your data type will be able to
+    /// deserialize from self-describing formats only, ruling out Bincode and
+    /// many others.
+    fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a `bool` value.
+    fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a `u8` value.
+    fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a `u16` value.
+    fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a `u32` value.
+    fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a `u64` value.
+    fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting an `i8` value.
+    fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting an `i16` value.
+    fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting an `i32` value.
+    fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting an `i64` value.
+    fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a `f32` value.
+    fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a `f64` value.
+    fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a `char` value.
+    fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a string value and does
+    /// not benefit from taking ownership of buffered data owned by the
+    /// `Deserializer`.
+    ///
+    /// If the `Visitor` would benefit from taking ownership of `String` data,
+    /// indiciate this to the `Deserializer` by using `deserialize_string`
+    /// instead.
+    fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a string value and would
+    /// benefit from taking ownership of buffered data owned by the
+    /// `Deserializer`.
+    ///
+    /// If the `Visitor` would not benefit from taking ownership of `String`
+    /// data, indicate that to the `Deserializer` by using `deserialize_str`
+    /// instead.
+    fn deserialize_string<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a byte array and does not
+    /// benefit from taking ownership of buffered data owned by the
+    /// `Deserializer`.
+    ///
+    /// If the `Visitor` would benefit from taking ownership of `Vec<u8>` data,
+    /// indicate this to the `Deserializer` by using `deserialize_byte_buf`
+    /// instead.
+    fn deserialize_bytes<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a byte array and would
+    /// benefit from taking ownership of buffered data owned by the
+    /// `Deserializer`.
+    ///
+    /// If the `Visitor` would not benefit from taking ownership of `Vec<u8>`
+    /// data, indicate that to the `Deserializer` by using `deserialize_bytes`
+    /// instead.
+    fn deserialize_byte_buf<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting an optional value.
+    ///
+    /// This allows deserializers that encode an optional value as a nullable
+    /// value to convert the null value into `None` and a regular value into
+    /// `Some(value)`.
+    fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a unit value.
+    fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a unit struct with a
+    /// particular name.
+    fn deserialize_unit_struct<V>(self,
+                                  name: &'static str,
+                                  visitor: V)
+                                  -> Result<V::Value, Self::Error>
+        where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a newtype struct with a
+    /// particular name.
+    fn deserialize_newtype_struct<V>(self,
+                                     name: &'static str,
+                                     visitor: V)
+                                     -> Result<V::Value, Self::Error>
+        where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a sequence of values.
+    fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a sequence of values and
+    /// knows how many values there are without looking at the serialized data.
+    fn deserialize_seq_fixed_size<V>(self,
+                                     len: usize,
+                                     visitor: V)
+                                     -> Result<V::Value, Self::Error>
+        where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a tuple value with a
+    /// particular number of elements.
+    fn deserialize_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value, Self::Error>
+        where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a tuple struct with a
+    /// particular name and number of fields.
+    fn deserialize_tuple_struct<V>(self,
+                                   name: &'static str,
+                                   len: usize,
+                                   visitor: V)
+                                   -> Result<V::Value, Self::Error>
+        where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a map of key-value pairs.
+    fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting a struct with a particular
+    /// name and fields.
+    fn deserialize_struct<V>(self,
+                             name: &'static str,
+                             fields: &'static [&'static str],
+                             visitor: V)
+                             -> Result<V::Value, Self::Error>
+        where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting the name of a struct
+    /// field.
+    fn deserialize_struct_field<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+        where V: Visitor;
+
+    /// Hint that the `Deserialize` type is expecting an enum value with a
+    /// particular name and possible variants.
+    fn deserialize_enum<V>(self,
+                           name: &'static str,
+                           variants: &'static [&'static str],
+                           visitor: V)
+                           -> Result<V::Value, Self::Error>
+        where V: Visitor;
+
+    /// Hint that the `Deserialize` type needs to deserialize a value whose type
+    /// doesn't matter because it is ignored.
+    ///
+    /// Deserializers for non-self-describing formats may not support this mode.
+    fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+        where V: Visitor;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// This trait represents a visitor that walks through a deserializer.
+///
+/// ```rust
+/// # use serde::de::{Error, Unexpected, Visitor};
+/// # use std::fmt;
+/// /// A visitor that deserializes a long string - a string containing at least
+/// /// some minimum number of bytes.
+/// # #[allow(dead_code)]
+/// struct LongString {
+///     min: usize,
+/// }
+///
+/// impl Visitor for LongString {
+///     type Value = String;
+///
+///     fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+///         write!(formatter, "a string containing at least {} bytes", self.min)
+///     }
+///
+///     fn visit_str<E>(self, s: &str) -> Result<Self::Value, E>
+///         where E: Error
+///     {
+///         if s.len() >= self.min {
+///             Ok(s.to_owned())
+///         } else {
+///             Err(Error::invalid_value(Unexpected::Str(s), &self))
+///         }
+///     }
+/// }
+/// ```
+pub trait Visitor: Sized {
+    /// The value produced by this visitor.
+    type Value;
+
+    /// Format a message stating what data this Visitor expects to receive.
+    ///
+    /// This is used in error messages. The message should complete the sentence
+    /// "This Visitor expects to receive ...", for example the message could be
+    /// "an integer between 0 and 64". The message should not be capitalized and
+    /// should not end with a period.
+    ///
+    /// ```rust
+    /// # use std::fmt;
+    /// # #[allow(dead_code)]
+    /// # struct S { max: usize }
+    /// # impl serde::de::Visitor for S {
+    /// # type Value = ();
+    /// fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+    ///     write!(formatter, "an integer between 0 and {}", self.max)
+    /// }
+    /// # }
+    /// ```
+    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result;
+
+    /// Deserialize a `bool` into a `Value`.
+    fn visit_bool<E>(self, v: bool) -> Result<Self::Value, E>
+        where E: Error
+    {
+        Err(Error::invalid_type(Unexpected::Bool(v), &self))
+    }
+
+    /// Deserialize an `i8` into a `Value`.
+    fn visit_i8<E>(self, v: i8) -> Result<Self::Value, E>
+        where E: Error
+    {
+        self.visit_i64(v as i64)
+    }
+
+    /// Deserialize an `i16` into a `Value`.
+    fn visit_i16<E>(self, v: i16) -> Result<Self::Value, E>
+        where E: Error
+    {
+        self.visit_i64(v as i64)
+    }
+
+    /// Deserialize an `i32` into a `Value`.
+    fn visit_i32<E>(self, v: i32) -> Result<Self::Value, E>
+        where E: Error
+    {
+        self.visit_i64(v as i64)
+    }
+
+    /// Deserialize an `i64` into a `Value`.
+    fn visit_i64<E>(self, v: i64) -> Result<Self::Value, E>
+        where E: Error
+    {
+        Err(Error::invalid_type(Unexpected::Signed(v), &self))
+    }
+
+    /// Deserialize a `u8` into a `Value`.
+    fn visit_u8<E>(self, v: u8) -> Result<Self::Value, E>
+        where E: Error
+    {
+        self.visit_u64(v as u64)
+    }
+
+    /// Deserialize a `u16` into a `Value`.
+    fn visit_u16<E>(self, v: u16) -> Result<Self::Value, E>
+        where E: Error
+    {
+        self.visit_u64(v as u64)
+    }
+
+    /// Deserialize a `u32` into a `Value`.
+    fn visit_u32<E>(self, v: u32) -> Result<Self::Value, E>
+        where E: Error
+    {
+        self.visit_u64(v as u64)
+    }
+
+    /// Deserialize a `u64` into a `Value`.
+    fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
+        where E: Error
+    {
+        Err(Error::invalid_type(Unexpected::Unsigned(v), &self))
+    }
+
+    /// Deserialize a `f32` into a `Value`.
+    fn visit_f32<E>(self, v: f32) -> Result<Self::Value, E>
+        where E: Error
+    {
+        self.visit_f64(v as f64)
+    }
+
+    /// Deserialize a `f64` into a `Value`.
+    fn visit_f64<E>(self, v: f64) -> Result<Self::Value, E>
+        where E: Error
+    {
+        Err(Error::invalid_type(Unexpected::Float(v), &self))
+    }
+
+    /// Deserialize a `char` into a `Value`.
+    #[inline]
+    fn visit_char<E>(self, v: char) -> Result<Self::Value, E>
+        where E: Error
+    {
+        self.visit_str(::utils::encode_utf8(v).as_str())
+    }
+
+    /// Deserialize a `&str` into a `Value`.
+    ///
+    /// This method allows the `Deserializer` to avoid a copy by retaining
+    /// ownership of any buffered data. `Deserialize` implementations that do
+    /// not benefit from taking ownership of `String` data should indicate that
+    /// to the deserializer by using `Deserializer::deserialize_str` rather than
+    /// `Deserializer::deserialize_string`.
+    ///
+    /// It is never correct to implement `visit_string` without implementing
+    /// `visit_str`. Implement neither, both, or just `visit_str`.
+    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
+        where E: Error
+    {
+        Err(Error::invalid_type(Unexpected::Str(v), &self))
+    }
+
+    /// Deserialize a `String` into a `Value`.
+    ///
+    /// This method allows the `Visitor` to avoid a copy by taking ownership of
+    /// a string created by the `Deserializer`. `Deserialize` implementations
+    /// that benefit from taking ownership of `String` data should indicate that
+    /// to the deserializer by using `Deserializer::deserialize_string` rather
+    /// than `Deserializer::deserialize_str`, although not every deserializer
+    /// will honor such a request.
+    ///
+    /// It is never correct to implement `visit_string` without implementing
+    /// `visit_str`. Implement neither, both, or just `visit_str`.
+    ///
+    /// The default implementation forwards to `visit_str` and then drops the
+    /// `String`.
+    #[inline]
+    #[cfg(any(feature = "std", feature = "collections"))]
+    fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
+        where E: Error
+    {
+        self.visit_str(&v)
+    }
+
+    /// Deserialize a `()` into a `Value`.
+    fn visit_unit<E>(self) -> Result<Self::Value, E>
+        where E: Error
+    {
+        Err(Error::invalid_type(Unexpected::Unit, &self))
+    }
+
+    /// Deserialize an absent optional `Value`.
+    fn visit_none<E>(self) -> Result<Self::Value, E>
+        where E: Error
+    {
+        Err(Error::invalid_type(Unexpected::Option, &self))
+    }
+
+    /// Deserialize a present optional `Value`.
+    fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
+        where D: Deserializer
+    {
+        let _ = deserializer;
+        Err(Error::invalid_type(Unexpected::Option, &self))
+    }
+
+    /// Deserialize `Value` as a newtype struct.
+    fn visit_newtype_struct<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
+        where D: Deserializer
+    {
+        let _ = deserializer;
+        Err(Error::invalid_type(Unexpected::NewtypeStruct, &self))
+    }
+
+    /// Deserialize `Value` as a sequence of elements.
+    fn visit_seq<V>(self, visitor: V) -> Result<Self::Value, V::Error>
+        where V: SeqVisitor
+    {
+        let _ = visitor;
+        Err(Error::invalid_type(Unexpected::Seq, &self))
+    }
+
+    /// Deserialize `Value` as a key-value map.
+    fn visit_map<V>(self, visitor: V) -> Result<Self::Value, V::Error>
+        where V: MapVisitor
+    {
+        let _ = visitor;
+        Err(Error::invalid_type(Unexpected::Map, &self))
+    }
+
+    /// Deserialize `Value` as an enum.
+    fn visit_enum<V>(self, visitor: V) -> Result<Self::Value, V::Error>
+        where V: EnumVisitor
+    {
+        let _ = visitor;
+        Err(Error::invalid_type(Unexpected::Enum, &self))
+    }
+
+    /// Deserialize a `&[u8]` into a `Value`.
+    ///
+    /// This method allows the `Deserializer` to avoid a copy by retaining
+    /// ownership of any buffered data. `Deserialize` implementations that do
+    /// not benefit from taking ownership of `Vec<u8>` data should indicate that
+    /// to the deserializer by using `Deserializer::deserialize_bytes` rather
+    /// than `Deserializer::deserialize_byte_buf`.
+    ///
+    /// It is never correct to implement `visit_byte_buf` without implementing
+    /// `visit_bytes`. Implement neither, both, or just `visit_bytes`.
+    fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
+        where E: Error
+    {
+        let _ = v;
+        Err(Error::invalid_type(Unexpected::Bytes(v), &self))
+    }
+
+    /// Deserialize a `Vec<u8>` into a `Value`.
+    ///
+    /// This method allows the `Visitor` to avoid a copy by taking ownership of
+    /// a byte buffer created by the `Deserializer`. `Deserialize`
+    /// implementations that benefit from taking ownership of `Vec<u8>` data
+    /// should indicate that to the deserializer by using
+    /// `Deserializer::deserialize_byte_buf` rather than
+    /// `Deserializer::deserialize_bytes`, although not every deserializer will
+    /// honor such a request.
+    ///
+    /// It is never correct to implement `visit_byte_buf` without implementing
+    /// `visit_bytes`. Implement neither, both, or just `visit_bytes`.
+    ///
+    /// The default implementation forwards to `visit_bytes` and then drops the
+    /// `Vec<u8>`.
+    #[cfg(any(feature = "std", feature = "collections"))]
+    fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<Self::Value, E>
+        where E: Error
+    {
+        self.visit_bytes(&v)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// `SeqVisitor` visits each item in a sequence.
+///
+/// This is a trait that a `Deserializer` passes to a `Visitor` implementation,
+/// which deserializes each item in a sequence.
+pub trait SeqVisitor {
+    /// The error type that can be returned if some error occurs during
+    /// deserialization.
+    type Error: Error;
+
+    /// This returns `Ok(Some(value))` for the next value in the sequence, or
+    /// `Ok(None)` if there are no more remaining items.
+    ///
+    /// `Deserialize` implementations should typically use `SeqVisitor::visit`
+    /// instead.
+    fn visit_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
+        where T: DeserializeSeed;
+
+    /// This returns `Ok(Some(value))` for the next value in the sequence, or
+    /// `Ok(None)` if there are no more remaining items.
+    ///
+    /// This method exists as a convenience for `Deserialize` implementations.
+    /// `SeqVisitor` implementations should not override the default behavior.
+    #[inline]
+    fn visit<T>(&mut self) -> Result<Option<T>, Self::Error>
+        where T: Deserialize
+    {
+        self.visit_seed(PhantomData)
+    }
+
+    /// Return the lower and upper bound of items remaining in the sequence.
+    #[inline]
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        (0, None)
+    }
+}
+
+impl<'a, V> SeqVisitor for &'a mut V
+    where V: SeqVisitor
+{
+    type Error = V::Error;
+
+    #[inline]
+    fn visit_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, V::Error>
+        where T: DeserializeSeed
+    {
+        (**self).visit_seed(seed)
+    }
+
+    #[inline]
+    fn visit<T>(&mut self) -> Result<Option<T>, V::Error>
+        where T: Deserialize
+    {
+        (**self).visit()
+    }
+
+    #[inline]
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        (**self).size_hint()
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// `MapVisitor` visits each item in a sequence.
+///
+/// This is a trait that a `Deserializer` passes to a `Visitor` implementation.
+pub trait MapVisitor {
+    /// The error type that can be returned if some error occurs during
+    /// deserialization.
+    type Error: Error;
+
+    /// This returns `Ok(Some(key))` for the next key in the map, or `Ok(None)`
+    /// if there are no more remaining entries.
+    ///
+    /// `Deserialize` implementations should typically use
+    /// `MapVisitor::visit_key` or `MapVisitor::visit` instead.
+    fn visit_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Self::Error>
+        where K: DeserializeSeed;
+
+    /// This returns a `Ok(value)` for the next value in the map.
+    ///
+    /// `Deserialize` implementations should typically use
+    /// `MapVisitor::visit_value` instead.
+    fn visit_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Self::Error>
+        where V: DeserializeSeed;
+
+    /// This returns `Ok(Some((key, value)))` for the next (key-value) pair in
+    /// the map, or `Ok(None)` if there are no more remaining items.
+    ///
+    /// `MapVisitor` implementations should override the default behavior if a
+    /// more efficient implementation is possible.
+    ///
+    /// `Deserialize` implementations should typically use `MapVisitor::visit`
+    /// instead.
+    #[inline]
+    fn visit_seed<K, V>(&mut self,
+                        kseed: K,
+                        vseed: V)
+                        -> Result<Option<(K::Value, V::Value)>, Self::Error>
+        where K: DeserializeSeed,
+              V: DeserializeSeed
+    {
+        match try!(self.visit_key_seed(kseed)) {
+            Some(key) => {
+                let value = try!(self.visit_value_seed(vseed));
+                Ok(Some((key, value)))
+            }
+            None => Ok(None),
+        }
+    }
+
+    /// This returns `Ok(Some(key))` for the next key in the map, or `Ok(None)`
+    /// if there are no more remaining entries.
+    ///
+    /// This method exists as a convenience for `Deserialize` implementations.
+    /// `MapVisitor` implementations should not override the default behavior.
+    #[inline]
+    fn visit_key<K>(&mut self) -> Result<Option<K>, Self::Error>
+        where K: Deserialize
+    {
+        self.visit_key_seed(PhantomData)
+    }
+
+    /// This returns a `Ok(value)` for the next value in the map.
+    ///
+    /// This method exists as a convenience for `Deserialize` implementations.
+    /// `MapVisitor` implementations should not override the default behavior.
+    #[inline]
+    fn visit_value<V>(&mut self) -> Result<V, Self::Error>
+        where V: Deserialize
+    {
+        self.visit_value_seed(PhantomData)
+    }
+
+    /// This returns `Ok(Some((key, value)))` for the next (key-value) pair in
+    /// the map, or `Ok(None)` if there are no more remaining items.
+    ///
+    /// This method exists as a convenience for `Deserialize` implementations.
+    /// `MapVisitor` implementations should not override the default behavior.
+    #[inline]
+    fn visit<K, V>(&mut self) -> Result<Option<(K, V)>, Self::Error>
+        where K: Deserialize,
+              V: Deserialize
+    {
+        self.visit_seed(PhantomData, PhantomData)
+    }
+
+    /// Return the lower and upper bound of items remaining in the sequence.
+    #[inline]
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        (0, None)
+    }
+}
+
+impl<'a, V_> MapVisitor for &'a mut V_
+    where V_: MapVisitor
+{
+    type Error = V_::Error;
+
+    #[inline]
+    fn visit_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>, Self::Error>
+        where K: DeserializeSeed
+    {
+        (**self).visit_key_seed(seed)
+    }
+
+    #[inline]
+    fn visit_value_seed<V>(&mut self, seed: V) -> Result<V::Value, Self::Error>
+        where V: DeserializeSeed
+    {
+        (**self).visit_value_seed(seed)
+    }
+
+    #[inline]
+    fn visit_seed<K, V>(&mut self,
+                        kseed: K,
+                        vseed: V)
+                        -> Result<Option<(K::Value, V::Value)>, Self::Error>
+        where K: DeserializeSeed,
+              V: DeserializeSeed
+    {
+        (**self).visit_seed(kseed, vseed)
+    }
+
+    #[inline]
+    fn visit<K, V>(&mut self) -> Result<Option<(K, V)>, V_::Error>
+        where K: Deserialize,
+              V: Deserialize
+    {
+        (**self).visit()
+    }
+
+    #[inline]
+    fn visit_key<K>(&mut self) -> Result<Option<K>, V_::Error>
+        where K: Deserialize
+    {
+        (**self).visit_key()
+    }
+
+    #[inline]
+    fn visit_value<V>(&mut self) -> Result<V, V_::Error>
+        where V: Deserialize
+    {
+        (**self).visit_value()
+    }
+
+    #[inline]
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        (**self).size_hint()
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// `EnumVisitor` is a visitor that is created by the `Deserializer` and passed
+/// to the `Deserialize` in order to identify which variant of an enum to
+/// deserialize.
+pub trait EnumVisitor: Sized {
+    /// The error type that can be returned if some error occurs during
+    /// deserialization.
+    type Error: Error;
+    /// The `Visitor` that will be used to deserialize the content of the enum
+    /// variant.
+    type Variant: VariantVisitor<Error = Self::Error>;
+
+    /// `visit_variant` is called to identify which variant to deserialize.
+    ///
+    /// `Deserialize` implementations should typically use
+    /// `EnumVisitor::visit_variant` instead.
+    fn visit_variant_seed<V>(self, seed: V) -> Result<(V::Value, Self::Variant), Self::Error>
+        where V: DeserializeSeed;
+
+    /// `visit_variant` is called to identify which variant to deserialize.
+    ///
+    /// This method exists as a convenience for `Deserialize` implementations.
+    /// `EnumVisitor` implementations should not override the default behavior.
+    #[inline]
+    fn visit_variant<V>(self) -> Result<(V, Self::Variant), Self::Error>
+        where V: Deserialize
+    {
+        self.visit_variant_seed(PhantomData)
+    }
+}
+
+/// `VariantVisitor` is a visitor that is created by the `Deserializer` and
+/// passed to the `Deserialize` to deserialize the content of a particular enum
+/// variant.
+pub trait VariantVisitor: Sized {
+    /// The error type that can be returned if some error occurs during
+    /// deserialization. Must match the error type of our `EnumVisitor`.
+    type Error: Error;
+
+    /// Called when deserializing a variant with no values.
+    ///
+    /// If the data contains a different type of variant, the following
+    /// `invalid_type` error should be constructed:
+    ///
+    /// ```rust,ignore
+    /// fn visit_unit(self) -> Result<(), Self::Error> {
+    ///     // What the data actually contained; suppose it is a tuple variant.
+    ///     let unexp = Unexpected::TupleVariant;
+    ///     Err(de::Error::invalid_type(unexp, &"unit variant"))
+    /// }
+    /// ```
+    fn visit_unit(self) -> Result<(), Self::Error>;
+
+    /// Called when deserializing a variant with a single value.
+    ///
+    /// `Deserialize` implementations should typically use
+    /// `VariantVisitor::visit_newtype` instead.
+    ///
+    /// If the data contains a different type of variant, the following
+    /// `invalid_type` error should be constructed:
+    ///
+    /// ```rust,ignore
+    /// fn visit_newtype_seed<T>(self, _seed: T) -> Result<T::Value, Self::Error>
+    ///     where T: de::DeserializeSeed
+    /// {
+    ///     // What the data actually contained; suppose it is a unit variant.
+    ///     let unexp = Unexpected::UnitVariant;
+    ///     Err(de::Error::invalid_type(unexp, &"newtype variant"))
+    /// }
+    /// ```
+    fn visit_newtype_seed<T>(self, seed: T) -> Result<T::Value, Self::Error>
+        where T: DeserializeSeed;
+
+    /// Called when deserializing a variant with a single value.
+    ///
+    /// This method exists as a convenience for `Deserialize` implementations.
+    /// `VariantVisitor` implementations should not override the default
+    /// behavior.
+    #[inline]
+    fn visit_newtype<T>(self) -> Result<T, Self::Error>
+        where T: Deserialize
+    {
+        self.visit_newtype_seed(PhantomData)
+    }
+
+    /// Called when deserializing a tuple-like variant.
+    ///
+    /// The `len` is the number of fields expected in the tuple variant.
+    ///
+    /// If the data contains a different type of variant, the following
+    /// `invalid_type` error should be constructed:
+    ///
+    /// ```rust,ignore
+    /// fn visit_tuple<V>(self,
+    ///                   _len: usize,
+    ///                   _visitor: V) -> Result<V::Value, Self::Error>
+    ///     where V: Visitor
+    /// {
+    ///     // What the data actually contained; suppose it is a unit variant.
+    ///     let unexp = Unexpected::UnitVariant;
+    ///     Err(Error::invalid_type(unexp, &"tuple variant"))
+    /// }
+    /// ```
+    fn visit_tuple<V>(self, len: usize, visitor: V) -> Result<V::Value, Self::Error>
+        where V: Visitor;
+
+    /// Called when deserializing a struct-like variant.
+    ///
+    /// The `fields` are the names of the fields of the struct variant.
+    ///
+    /// If the data contains a different type of variant, the following
+    /// `invalid_type` error should be constructed:
+    ///
+    /// ```rust,ignore
+    /// fn visit_struct<V>(self,
+    ///                    _fields: &'static [&'static str],
+    ///                    _visitor: V) -> Result<V::Value, Self::Error>
+    ///     where V: Visitor
+    /// {
+    ///     // What the data actually contained; suppose it is a unit variant.
+    ///     let unexp = Unexpected::UnitVariant;
+    ///     Err(Error::invalid_type(unexp, &"struct variant"))
+    /// }
+    /// ```
+    fn visit_struct<V>(self,
+                       fields: &'static [&'static str],
+                       visitor: V)
+                       -> Result<V::Value, Self::Error>
+        where V: Visitor;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// Used in error messages.
+///
+/// - expected `a`
+/// - expected `a` or `b`
+/// - expected one of `a`, `b`, `c`
+///
+/// The slice of names must not be empty.
+struct OneOf {
+    names: &'static [&'static str],
+}
+
+impl Display for OneOf {
+    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        match self.names.len() {
+            0 => panic!(), // special case elsewhere
+            1 => write!(formatter, "`{}`", self.names[0]),
+            2 => write!(formatter, "`{}` or `{}`", self.names[0], self.names[1]),
+            _ => {
+                try!(write!(formatter, "one of "));
+                for (i, alt) in self.names.iter().enumerate() {
+                    if i > 0 {
+                        try!(write!(formatter, ", "));
+                    }
+                    try!(write!(formatter, "`{}`", alt));
+                }
+                Ok(())
+            }
+        }
+    }
+}
rename from third_party/rust/serde/src/de/private.rs
rename to third_party/rust/serde-0.9.9/src/de/private.rs
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde-0.9.9/src/de/value.rs
@@ -0,0 +1,1048 @@
+//! This module supports deserializing from primitives with the `ValueDeserializer` trait.
+
+#[cfg(feature = "std")]
+use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, btree_map, btree_set, hash_map,
+                       hash_set};
+#[cfg(feature = "std")]
+use std::borrow::Cow;
+#[cfg(feature = "std")]
+use std::vec;
+
+#[cfg(all(feature = "collections", not(feature = "std")))]
+use collections::{BTreeMap, BTreeSet, Vec, String, btree_map, btree_set, vec};
+#[cfg(all(feature = "collections", not(feature = "std")))]
+use collections::borrow::Cow;
+#[cfg(all(feature = "collections", not(feature = "std")))]
+use collections::boxed::Box;
+#[cfg(all(feature = "collections", not(feature = "std")))]
+use collections::string::ToString;
+
+#[cfg(feature = "std")]
+use core::hash::Hash;
+#[cfg(feature = "std")]
+use std::error;
+#[cfg(not(feature = "std"))]
+use error;
+
+use core::fmt::{self, Display};
+use core::iter::{self, Iterator};
+use core::marker::PhantomData;
+
+use de::{self, Expected, SeqVisitor};
+use bytes;
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// This represents all the possible errors that can occur using the `ValueDeserializer`.
+#[derive(Clone, Debug, PartialEq)]
+pub struct Error {
+    err: ErrorImpl,
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+type ErrorImpl = Box<str>;
+#[cfg(not(any(feature = "std", feature = "collections")))]
+type ErrorImpl = ();
+
+impl de::Error for Error {
+    #[cfg(any(feature = "std", feature = "collections"))]
+    fn custom<T: Display>(msg: T) -> Self {
+        Error { err: msg.to_string().into_boxed_str() }
+    }
+
+    #[cfg(not(any(feature = "std", feature = "collections")))]
+    fn custom<T: Display>(_msg: T) -> Self {
+        Error { err: () }
+    }
+}
+
+impl Display for Error {
+    #[cfg(any(feature = "std", feature = "collections"))]
+    fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+        formatter.write_str(&self.err)
+    }
+
+    #[cfg(not(any(feature = "std", feature = "collections")))]
+    fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+        formatter.write_str("Serde deserialization error")
+    }
+}
+
+impl error::Error for Error {
+    #[cfg(any(feature = "std", feature = "collections"))]
+    fn description(&self) -> &str {
+        &self.err
+    }
+
+    #[cfg(not(any(feature = "std", feature = "collections")))]
+    fn description(&self) -> &str {
+        "Serde deserialization error"
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// This trait converts primitive types into a deserializer.
+pub trait ValueDeserializer<E: de::Error = Error> {
+    /// The actual deserializer type.
+    type Deserializer: de::Deserializer<Error = E>;
+
+    /// Convert this value into a deserializer.
+    fn into_deserializer(self) -> Self::Deserializer;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+impl<E> ValueDeserializer<E> for ()
+    where E: de::Error
+{
+    type Deserializer = UnitDeserializer<E>;
+
+    fn into_deserializer(self) -> UnitDeserializer<E> {
+        UnitDeserializer { marker: PhantomData }
+    }
+}
+
+/// A helper deserializer that deserializes a `()`.
+pub struct UnitDeserializer<E> {
+    marker: PhantomData<E>,
+}
+
+impl<E> de::Deserializer for UnitDeserializer<E>
+    where E: de::Error
+{
+    type Error = E;
+
+    forward_to_deserialize! {
+        bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit seq
+        seq_fixed_size bytes map unit_struct newtype_struct tuple_struct struct
+        struct_field tuple enum ignored_any byte_buf
+    }
+
+    fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+        where V: de::Visitor
+    {
+        visitor.visit_unit()
+    }
+
+    fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+        where V: de::Visitor
+    {
+        visitor.visit_none()
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+macro_rules! primitive_deserializer {
+    ($ty:ty, $name:ident, $method:ident $($cast:tt)*) => {
+        /// A helper deserializer that deserializes a number.
+        pub struct $name<E> {
+            value: $ty,
+            marker: PhantomData<E>
+        }
+
+        impl<E> ValueDeserializer<E> for $ty
+            where E: de::Error,
+        {
+            type Deserializer = $name<E>;
+
+            fn into_deserializer(self) -> $name<E> {
+                $name {
+                    value: self,
+                    marker: PhantomData,
+                }
+            }
+        }
+
+        impl<E> de::Deserializer for $name<E>
+            where E: de::Error,
+        {
+            type Error = E;
+
+            forward_to_deserialize! {
+                bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit
+                option seq seq_fixed_size bytes map unit_struct newtype_struct
+                tuple_struct struct struct_field tuple enum ignored_any byte_buf
+            }
+
+            fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+                where V: de::Visitor,
+            {
+                visitor.$method(self.value $($cast)*)
+            }
+        }
+    }
+}
+
+primitive_deserializer!(bool, BoolDeserializer, visit_bool);
+primitive_deserializer!(i8, I8Deserializer, visit_i8);
+primitive_deserializer!(i16, I16Deserializer, visit_i16);
+primitive_deserializer!(i32, I32Deserializer, visit_i32);
+primitive_deserializer!(i64, I64Deserializer, visit_i64);
+primitive_deserializer!(isize, IsizeDeserializer, visit_i64 as i64);
+primitive_deserializer!(u8, U8Deserializer, visit_u8);
+primitive_deserializer!(u16, U16Deserializer, visit_u16);
+primitive_deserializer!(u32, U32Deserializer, visit_u32);
+primitive_deserializer!(u64, U64Deserializer, visit_u64);
+primitive_deserializer!(usize, UsizeDeserializer, visit_u64 as u64);
+primitive_deserializer!(f32, F32Deserializer, visit_f32);
+primitive_deserializer!(f64, F64Deserializer, visit_f64);
+primitive_deserializer!(char, CharDeserializer, visit_char);
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// A helper deserializer that deserializes a `&str`.
+pub struct StrDeserializer<'a, E> {
+    value: &'a str,
+    marker: PhantomData<E>,
+}
+
+impl<'a, E> ValueDeserializer<E> for &'a str
+    where E: de::Error
+{
+    type Deserializer = StrDeserializer<'a, E>;
+
+    fn into_deserializer(self) -> StrDeserializer<'a, E> {
+        StrDeserializer {
+            value: self,
+            marker: PhantomData,
+        }
+    }
+}
+
+impl<'a, E> de::Deserializer for StrDeserializer<'a, E>
+    where E: de::Error
+{
+    type Error = E;
+
+    fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+        where V: de::Visitor
+    {
+        visitor.visit_str(self.value)
+    }
+
+    fn deserialize_enum<V>(self,
+                           _name: &str,
+                           _variants: &'static [&'static str],
+                           visitor: V)
+                           -> Result<V::Value, Self::Error>
+        where V: de::Visitor
+    {
+        visitor.visit_enum(self)
+    }
+
+    forward_to_deserialize! {
+        bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option
+        seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct
+        struct struct_field tuple ignored_any byte_buf
+    }
+}
+
+impl<'a, E> de::EnumVisitor for StrDeserializer<'a, E>
+    where E: de::Error
+{
+    type Error = E;
+    type Variant = private::UnitOnly<E>;
+
+    fn visit_variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error>
+        where T: de::DeserializeSeed
+    {
+        seed.deserialize(self).map(private::unit_only)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// A helper deserializer that deserializes a `String`.
+#[cfg(any(feature = "std", feature = "collections"))]
+pub struct StringDeserializer<E> {
+    value: String,
+    marker: PhantomData<E>,
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<E> ValueDeserializer<E> for String
+    where E: de::Error
+{
+    type Deserializer = StringDeserializer<E>;
+
+    fn into_deserializer(self) -> StringDeserializer<E> {
+        StringDeserializer {
+            value: self,
+            marker: PhantomData,
+        }
+    }
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<E> de::Deserializer for StringDeserializer<E>
+    where E: de::Error
+{
+    type Error = E;
+
+    fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+        where V: de::Visitor
+    {
+        visitor.visit_string(self.value)
+    }
+
+    fn deserialize_enum<V>(self,
+                           _name: &str,
+                           _variants: &'static [&'static str],
+                           visitor: V)
+                           -> Result<V::Value, Self::Error>
+        where V: de::Visitor
+    {
+        visitor.visit_enum(self)
+    }
+
+    forward_to_deserialize! {
+        bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option
+        seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct
+        struct struct_field tuple ignored_any byte_buf
+    }
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<'a, E> de::EnumVisitor for StringDeserializer<E>
+    where E: de::Error
+{
+    type Error = E;
+    type Variant = private::UnitOnly<E>;
+
+    fn visit_variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error>
+        where T: de::DeserializeSeed
+    {
+        seed.deserialize(self).map(private::unit_only)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// A helper deserializer that deserializes a `String`.
+#[cfg(any(feature = "std", feature = "collections"))]
+pub struct CowStrDeserializer<'a, E> {
+    value: Cow<'a, str>,
+    marker: PhantomData<E>,
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<'a, E> ValueDeserializer<E> for Cow<'a, str>
+    where E: de::Error
+{
+    type Deserializer = CowStrDeserializer<'a, E>;
+
+    fn into_deserializer(self) -> CowStrDeserializer<'a, E> {
+        CowStrDeserializer {
+            value: self,
+            marker: PhantomData,
+        }
+    }
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<'a, E> de::Deserializer for CowStrDeserializer<'a, E>
+    where E: de::Error
+{
+    type Error = E;
+
+    fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+        where V: de::Visitor
+    {
+        match self.value {
+            Cow::Borrowed(string) => visitor.visit_str(string),
+            Cow::Owned(string) => visitor.visit_string(string),
+        }
+    }
+
+    fn deserialize_enum<V>(self,
+                           _name: &str,
+                           _variants: &'static [&'static str],
+                           visitor: V)
+                           -> Result<V::Value, Self::Error>
+        where V: de::Visitor
+    {
+        visitor.visit_enum(self)
+    }
+
+    forward_to_deserialize! {
+        bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option
+        seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct
+        struct struct_field tuple ignored_any byte_buf
+    }
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<'a, E> de::EnumVisitor for CowStrDeserializer<'a, E>
+    where E: de::Error
+{
+    type Error = E;
+    type Variant = private::UnitOnly<E>;
+
+    fn visit_variant_seed<T>(self, seed: T) -> Result<(T::Value, Self::Variant), Self::Error>
+        where T: de::DeserializeSeed
+    {
+        seed.deserialize(self).map(private::unit_only)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// A helper deserializer that deserializes a sequence.
+pub struct SeqDeserializer<I, E> {
+    iter: iter::Fuse<I>,
+    count: usize,
+    marker: PhantomData<E>,
+}
+
+impl<I, E> SeqDeserializer<I, E>
+    where I: Iterator,
+          E: de::Error
+{
+    /// Construct a new `SeqDeserializer<I>`.
+    pub fn new(iter: I) -> Self {
+        SeqDeserializer {
+            iter: iter.fuse(),
+            count: 0,
+            marker: PhantomData,
+        }
+    }
+
+    /// Check for remaining elements after passing a `SeqDeserializer` to
+    /// `Visitor::visit_seq`.
+    pub fn end(mut self) -> Result<(), E> {
+        let mut remaining = 0;
+        while self.iter.next().is_some() {
+            remaining += 1;
+        }
+        if remaining == 0 {
+            Ok(())
+        } else {
+            // First argument is the number of elements in the data, second
+            // argument is the number of elements expected by the Deserialize.
+            Err(de::Error::invalid_length(self.count + remaining, &ExpectedInSeq(self.count)))
+        }
+    }
+}
+
+impl<I, T, E> de::Deserializer for SeqDeserializer<I, E>
+    where I: Iterator<Item = T>,
+          T: ValueDeserializer<E>,
+          E: de::Error
+{
+    type Error = E;
+
+    fn deserialize<V>(mut self, visitor: V) -> Result<V::Value, Self::Error>
+        where V: de::Visitor
+    {
+        let v = try!(visitor.visit_seq(&mut self));
+        try!(self.end());
+        Ok(v)
+    }
+
+    forward_to_deserialize! {
+        bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option
+        seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct
+        struct struct_field tuple enum ignored_any byte_buf
+    }
+}
+
+impl<I, T, E> de::SeqVisitor for SeqDeserializer<I, E>
+    where I: Iterator<Item = T>,
+          T: ValueDeserializer<E>,
+          E: de::Error
+{
+    type Error = E;
+
+    fn visit_seed<V>(&mut self, seed: V) -> Result<Option<V::Value>, Self::Error>
+        where V: de::DeserializeSeed
+    {
+        match self.iter.next() {
+            Some(value) => {
+                self.count += 1;
+                seed.deserialize(value.into_deserializer()).map(Some)
+            }
+            None => Ok(None),
+        }
+    }
+
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        self.iter.size_hint()
+    }
+}
+
+struct ExpectedInSeq(usize);
+
+impl Expected for ExpectedInSeq {
+    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        if self.0 == 1 {
+            write!(formatter, "1 element in sequence")
+        } else {
+            write!(formatter, "{} elements in sequence", self.0)
+        }
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<T, E> ValueDeserializer<E> for Vec<T>
+    where T: ValueDeserializer<E>,
+          E: de::Error
+{
+    type Deserializer = SeqDeserializer<vec::IntoIter<T>, E>;
+
+    fn into_deserializer(self) -> Self::Deserializer {
+        SeqDeserializer::new(self.into_iter())
+    }
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<T, E> ValueDeserializer<E> for BTreeSet<T>
+    where T: ValueDeserializer<E> + Eq + Ord,
+          E: de::Error
+{
+    type Deserializer = SeqDeserializer<btree_set::IntoIter<T>, E>;
+
+    fn into_deserializer(self) -> Self::Deserializer {
+        SeqDeserializer::new(self.into_iter())
+    }
+}
+
+#[cfg(feature = "std")]
+impl<T, E> ValueDeserializer<E> for HashSet<T>
+    where T: ValueDeserializer<E> + Eq + Hash,
+          E: de::Error
+{
+    type Deserializer = SeqDeserializer<hash_set::IntoIter<T>, E>;
+
+    fn into_deserializer(self) -> Self::Deserializer {
+        SeqDeserializer::new(self.into_iter())
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// A helper deserializer that deserializes a sequence using a `SeqVisitor`.
+pub struct SeqVisitorDeserializer<V_, E> {
+    visitor: V_,
+    marker: PhantomData<E>,
+}
+
+impl<V_, E> SeqVisitorDeserializer<V_, E>
+    where V_: de::SeqVisitor<Error = E>,
+          E: de::Error
+{
+    /// Construct a new `SeqVisitorDeserializer<V_, E>`.
+    pub fn new(visitor: V_) -> Self {
+        SeqVisitorDeserializer {
+            visitor: visitor,
+            marker: PhantomData,
+        }
+    }
+}
+
+impl<V_, E> de::Deserializer for SeqVisitorDeserializer<V_, E>
+    where V_: de::SeqVisitor<Error = E>,
+          E: de::Error
+{
+    type Error = E;
+
+    fn deserialize<V: de::Visitor>(self, visitor: V) -> Result<V::Value, Self::Error> {
+        visitor.visit_seq(self.visitor)
+    }
+
+    forward_to_deserialize! {
+        bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option
+        seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct
+        struct struct_field tuple enum ignored_any byte_buf
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// A helper deserializer that deserializes a map.
+pub struct MapDeserializer<I, E>
+    where I: Iterator,
+          I::Item: private::Pair,
+          <I::Item as private::Pair>::First: ValueDeserializer<E>,
+          <I::Item as private::Pair>::Second: ValueDeserializer<E>,
+          E: de::Error
+{
+    iter: iter::Fuse<I>,
+    value: Option<<I::Item as private::Pair>::Second>,
+    count: usize,
+    marker: PhantomData<E>,
+}
+
+impl<I, E> MapDeserializer<I, E>
+    where I: Iterator,
+          I::Item: private::Pair,
+          <I::Item as private::Pair>::First: ValueDeserializer<E>,
+          <I::Item as private::Pair>::Second: ValueDeserializer<E>,
+          E: de::Error
+{
+    /// Construct a new `MapDeserializer<I, K, V, E>`.
+    pub fn new(iter: I) -> Self {
+        MapDeserializer {
+            iter: iter.fuse(),
+            value: None,
+            count: 0,
+            marker: PhantomData,
+        }
+    }
+
+    /// Check for remaining elements after passing a `MapDeserializer` to
+    /// `Visitor::visit_map`.
+    pub fn end(mut self) -> Result<(), E> {
+        let mut remaining = 0;
+        while self.iter.next().is_some() {
+            remaining += 1;
+        }
+        if remaining == 0 {
+            Ok(())
+        } else {
+            // First argument is the number of elements in the data, second
+            // argument is the number of elements expected by the Deserialize.
+            Err(de::Error::invalid_length(self.count + remaining, &ExpectedInMap(self.count)))
+        }
+    }
+
+    fn next_pair
+        (&mut self)
+         -> Option<(<I::Item as private::Pair>::First, <I::Item as private::Pair>::Second)> {
+        match self.iter.next() {
+            Some(kv) => {
+                self.count += 1;
+                Some(private::Pair::split(kv))
+            }
+            None => None,
+        }
+    }
+}
+
+impl<I, E> de::Deserializer for MapDeserializer<I, E>
+    where I: Iterator,
+          I::Item: private::Pair,
+          <I::Item as private::Pair>::First: ValueDeserializer<E>,
+          <I::Item as private::Pair>::Second: ValueDeserializer<E>,
+          E: de::Error
+{
+    type Error = E;
+
+    fn deserialize<V_>(mut self, visitor: V_) -> Result<V_::Value, Self::Error>
+        where V_: de::Visitor
+    {
+        let value = try!(visitor.visit_map(&mut self));
+        try!(self.end());
+        Ok(value)
+    }
+
+    fn deserialize_seq<V_>(mut self, visitor: V_) -> Result<V_::Value, Self::Error>
+        where V_: de::Visitor
+    {
+        let value = try!(visitor.visit_seq(&mut self));
+        try!(self.end());
+        Ok(value)
+    }
+
+    fn deserialize_seq_fixed_size<V_>(self,
+                                      _len: usize,
+                                      visitor: V_)
+                                      -> Result<V_::Value, Self::Error>
+        where V_: de::Visitor
+    {
+        self.deserialize_seq(visitor)
+    }
+
+    forward_to_deserialize! {
+        bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option
+        bytes map unit_struct newtype_struct tuple_struct struct struct_field
+        tuple enum ignored_any byte_buf
+    }
+}
+
+impl<I, E> de::MapVisitor for MapDeserializer<I, E>
+    where I: Iterator,
+          I::Item: private::Pair,
+          <I::Item as private::Pair>::First: ValueDeserializer<E>,
+          <I::Item as private::Pair>::Second: ValueDeserializer<E>,
+          E: de::Error
+{
+    type Error = E;
+
+    fn visit_key_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
+        where T: de::DeserializeSeed
+    {
+        match self.next_pair() {
+            Some((key, value)) => {
+                self.value = Some(value);
+                seed.deserialize(key.into_deserializer()).map(Some)
+            }
+            None => Ok(None),
+        }
+    }
+
+    fn visit_value_seed<T>(&mut self, seed: T) -> Result<T::Value, Self::Error>
+        where T: de::DeserializeSeed
+    {
+        let value = self.value.take();
+        // Panic because this indicates a bug in the program rather than an
+        // expected failure.
+        let value = value.expect("MapVisitor::visit_value called before visit_key");
+        seed.deserialize(value.into_deserializer())
+    }
+
+    fn visit_seed<TK, TV>(&mut self,
+                          kseed: TK,
+                          vseed: TV)
+                          -> Result<Option<(TK::Value, TV::Value)>, Self::Error>
+        where TK: de::DeserializeSeed,
+              TV: de::DeserializeSeed
+    {
+        match self.next_pair() {
+            Some((key, value)) => {
+                let key = try!(kseed.deserialize(key.into_deserializer()));
+                let value = try!(vseed.deserialize(value.into_deserializer()));
+                Ok(Some((key, value)))
+            }
+            None => Ok(None),
+        }
+    }
+
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        self.iter.size_hint()
+    }
+}
+
+impl<I, E> de::SeqVisitor for MapDeserializer<I, E>
+    where I: Iterator,
+          I::Item: private::Pair,
+          <I::Item as private::Pair>::First: ValueDeserializer<E>,
+          <I::Item as private::Pair>::Second: ValueDeserializer<E>,
+          E: de::Error
+{
+    type Error = E;
+
+    fn visit_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
+        where T: de::DeserializeSeed
+    {
+        match self.next_pair() {
+            Some((k, v)) => {
+                let de = PairDeserializer(k, v, PhantomData);
+                seed.deserialize(de).map(Some)
+            }
+            None => Ok(None),
+        }
+    }
+
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        self.iter.size_hint()
+    }
+}
+
+// Used in the `impl SeqVisitor for MapDeserializer` to visit the map as a
+// sequence of pairs.
+struct PairDeserializer<A, B, E>(A, B, PhantomData<E>);
+
+impl<A, B, E> de::Deserializer for PairDeserializer<A, B, E>
+    where A: ValueDeserializer<E>,
+          B: ValueDeserializer<E>,
+          E: de::Error
+{
+    type Error = E;
+
+    forward_to_deserialize! {
+        bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option
+        bytes map unit_struct newtype_struct tuple_struct struct struct_field
+        tuple enum ignored_any byte_buf
+    }
+
+    fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+        where V: de::Visitor
+    {
+        self.deserialize_seq(visitor)
+    }
+
+    fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+        where V: de::Visitor
+    {
+        let mut pair_visitor = PairVisitor(Some(self.0), Some(self.1), PhantomData);
+        let pair = try!(visitor.visit_seq(&mut pair_visitor));
+        if pair_visitor.1.is_none() {
+            Ok(pair)
+        } else {
+            let remaining = pair_visitor.size_hint().0;
+            // First argument is the number of elements in the data, second
+            // argument is the number of elements expected by the Deserialize.
+            Err(de::Error::invalid_length(2, &ExpectedInSeq(2 - remaining)))
+        }
+    }
+
+    fn deserialize_seq_fixed_size<V>(self, len: usize, visitor: V) -> Result<V::Value, Self::Error>
+        where V: de::Visitor
+    {
+        if len == 2 {
+            self.deserialize_seq(visitor)
+        } else {
+            // First argument is the number of elements in the data, second
+            // argument is the number of elements expected by the Deserialize.
+            Err(de::Error::invalid_length(2, &ExpectedInSeq(len)))
+        }
+    }
+}
+
+struct PairVisitor<A, B, E>(Option<A>, Option<B>, PhantomData<E>);
+
+impl<A, B, E> de::SeqVisitor for PairVisitor<A, B, E>
+    where A: ValueDeserializer<E>,
+          B: ValueDeserializer<E>,
+          E: de::Error
+{
+    type Error = E;
+
+    fn visit_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>, Self::Error>
+        where T: de::DeserializeSeed
+    {
+        if let Some(k) = self.0.take() {
+            seed.deserialize(k.into_deserializer()).map(Some)
+        } else if let Some(v) = self.1.take() {
+            seed.deserialize(v.into_deserializer()).map(Some)
+        } else {
+            Ok(None)
+        }
+    }
+
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        let len = if self.0.is_some() {
+            2
+        } else if self.1.is_some() {
+            1
+        } else {
+            0
+        };
+        (len, Some(len))
+    }
+}
+
+struct ExpectedInMap(usize);
+
+impl Expected for ExpectedInMap {
+    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        if self.0 == 1 {
+            write!(formatter, "1 element in map")
+        } else {
+            write!(formatter, "{} elements in map", self.0)
+        }
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<K, V, E> ValueDeserializer<E> for BTreeMap<K, V>
+    where K: ValueDeserializer<E> + Eq + Ord,
+          V: ValueDeserializer<E>,
+          E: de::Error
+{
+    type Deserializer = MapDeserializer<btree_map::IntoIter<K, V>, E>;
+
+    fn into_deserializer(self) -> Self::Deserializer {
+        MapDeserializer::new(self.into_iter())
+    }
+}
+
+#[cfg(feature = "std")]
+impl<K, V, E> ValueDeserializer<E> for HashMap<K, V>
+    where K: ValueDeserializer<E> + Eq + Hash,
+          V: ValueDeserializer<E>,
+          E: de::Error
+{
+    type Deserializer = MapDeserializer<hash_map::IntoIter<K, V>, E>;
+
+    fn into_deserializer(self) -> Self::Deserializer {
+        MapDeserializer::new(self.into_iter())
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// A helper deserializer that deserializes a map using a `MapVisitor`.
+pub struct MapVisitorDeserializer<V_, E> {
+    visitor: V_,
+    marker: PhantomData<E>,
+}
+
+impl<V_, E> MapVisitorDeserializer<V_, E>
+    where V_: de::MapVisitor<Error = E>,
+          E: de::Error
+{
+    /// Construct a new `MapVisitorDeserializer<V_, E>`.
+    pub fn new(visitor: V_) -> Self {
+        MapVisitorDeserializer {
+            visitor: visitor,
+            marker: PhantomData,
+        }
+    }
+}
+
+impl<V_, E> de::Deserializer for MapVisitorDeserializer<V_, E>
+    where V_: de::MapVisitor<Error = E>,
+          E: de::Error
+{
+    type Error = E;
+
+    fn deserialize<V: de::Visitor>(self, visitor: V) -> Result<V::Value, Self::Error> {
+        visitor.visit_map(self.visitor)
+    }
+
+    forward_to_deserialize! {
+        bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option
+        seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct
+        struct struct_field tuple enum ignored_any byte_buf
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+impl<'a, E> ValueDeserializer<E> for bytes::Bytes<'a>
+    where E: de::Error
+{
+    type Deserializer = BytesDeserializer<'a, E>;
+
+    fn into_deserializer(self) -> BytesDeserializer<'a, E> {
+        BytesDeserializer {
+            value: self.into(),
+            marker: PhantomData,
+        }
+    }
+}
+
+/// A helper deserializer that deserializes a `&[u8]`.
+pub struct BytesDeserializer<'a, E> {
+    value: &'a [u8],
+    marker: PhantomData<E>,
+}
+
+impl<'a, E> de::Deserializer for BytesDeserializer<'a, E>
+    where E: de::Error
+{
+    type Error = E;
+
+    fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+        where V: de::Visitor
+    {
+        visitor.visit_bytes(self.value)
+    }
+
+    forward_to_deserialize! {
+        bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option
+        seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct
+        struct struct_field tuple enum ignored_any byte_buf
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<E> ValueDeserializer<E> for bytes::ByteBuf
+    where E: de::Error
+{
+    type Deserializer = ByteBufDeserializer<E>;
+
+    fn into_deserializer(self) -> Self::Deserializer {
+        ByteBufDeserializer {
+            value: self.into(),
+            marker: PhantomData,
+        }
+    }
+}
+
+/// A helper deserializer that deserializes a `Vec<u8>`.
+#[cfg(any(feature = "std", feature = "collections"))]
+pub struct ByteBufDeserializer<E> {
+    value: Vec<u8>,
+    marker: PhantomData<E>,
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<E> de::Deserializer for ByteBufDeserializer<E>
+    where E: de::Error
+{
+    type Error = E;
+
+    fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+        where V: de::Visitor
+    {
+        visitor.visit_byte_buf(self.value)
+    }
+
+    forward_to_deserialize! {
+        bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option
+        seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct
+        struct struct_field tuple enum ignored_any byte_buf
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+mod private {
+    use de::{self, Unexpected};
+    use core::marker::PhantomData;
+
+    pub struct UnitOnly<E> {
+        marker: PhantomData<E>,
+    }
+
+    pub fn unit_only<T, E>(t: T) -> (T, UnitOnly<E>) {
+        (t, UnitOnly { marker: PhantomData })
+    }
+
+    impl<E> de::VariantVisitor for UnitOnly<E>
+        where E: de::Error
+    {
+        type Error = E;
+
+        fn visit_unit(self) -> Result<(), Self::Error> {
+            Ok(())
+        }
+
+        fn visit_newtype_seed<T>(self, _seed: T) -> Result<T::Value, Self::Error>
+            where T: de::DeserializeSeed
+        {
+            Err(de::Error::invalid_type(Unexpected::UnitVariant, &"newtype variant"))
+        }
+
+        fn visit_tuple<V>(self, _len: usize, _visitor: V) -> Result<V::Value, Self::Error>
+            where V: de::Visitor
+        {
+            Err(de::Error::invalid_type(Unexpected::UnitVariant, &"tuple variant"))
+        }
+
+        fn visit_struct<V>(self,
+                           _fields: &'static [&'static str],
+                           _visitor: V)
+                           -> Result<V::Value, Self::Error>
+            where V: de::Visitor
+        {
+            Err(de::Error::invalid_type(Unexpected::UnitVariant, &"struct variant"))
+        }
+    }
+
+    /// Avoid having to restate the generic types on `MapDeserializer`. The
+    /// `Iterator::Item` contains enough information to figure out K and V.
+    pub trait Pair {
+        type First;
+        type Second;
+        fn split(self) -> (Self::First, Self::Second);
+    }
+
+    impl<A, B> Pair for (A, B) {
+        type First = A;
+        type Second = B;
+        fn split(self) -> (A, B) {
+            self
+        }
+    }
+}
rename from third_party/rust/serde/src/error.rs
rename to third_party/rust/serde-0.9.9/src/error.rs
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde-0.9.9/src/export.rs
@@ -0,0 +1,34 @@
+#[cfg(all(feature = "collections", not(feature = "std")))]
+use collections::String;
+
+#[cfg(feature = "std")]
+use std::borrow::Cow;
+#[cfg(all(feature = "collections", not(feature = "std")))]
+use collections::borrow::Cow;
+
+pub use core::default::Default;
+pub use core::fmt;
+pub use core::marker::PhantomData;
+pub use core::option::Option::{self, None, Some};
+pub use core::result::Result::{self, Ok, Err};
+
+#[cfg(any(feature = "collections", feature = "std"))]
+pub fn from_utf8_lossy(bytes: &[u8]) -> Cow<str> {
+    String::from_utf8_lossy(bytes)
+}
+
+// The generated code calls this like:
+//
+//     let value = &_serde::export::from_utf8_lossy(bytes);
+//     Err(_serde::de::Error::unknown_variant(value, VARIANTS))
+//
+// so it is okay for the return type to be different from the std case as long
+// as the above works.
+#[cfg(not(any(feature = "collections", feature = "std")))]
+pub fn from_utf8_lossy(bytes: &[u8]) -> &str {
+    use core::str;
+    // Three unicode replacement characters if it fails. They look like a
+    // white-on-black question mark. The user will recognize it as invalid
+    // UTF-8.
+    str::from_utf8(bytes).unwrap_or("\u{fffd}\u{fffd}\u{fffd}")
+}
rename from third_party/rust/serde/src/iter.rs
rename to third_party/rust/serde-0.9.9/src/iter.rs
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde-0.9.9/src/lib.rs
@@ -0,0 +1,107 @@
+//! # Serde
+//!
+//! Serde is a framework for ***ser***ializing and ***de***serializing Rust data
+//! structures efficiently and generically.
+//!
+//! The Serde ecosystem consists of data structures that know how to serialize
+//! and deserialize themselves along with data formats that know how to
+//! serialize and deserialize other things. Serde provides the layer by which
+//! these two groups interact with each other, allowing any supported data
+//! structure to be serialized and deserialized using any supported data format.
+//!
+//! See the Serde website https://serde.rs/ for additional documentation and
+//! usage examples.
+//!
+//! ### Design
+//!
+//! Where many other languages rely on runtime reflection for serializing data,
+//! Serde is instead built on Rust's powerful trait system. A data structure
+//! that knows how to serialize and deserialize itself is one that implements
+//! Serde's `Serialize` and `Deserialize` traits (or uses Serde's code
+//! generation to automatically derive implementations at compile time). This
+//! avoids any overhead of reflection or runtime type information. In fact in
+//! many situations the interaction between data structure and data format can
+//! be completely optimized away by the Rust compiler, leaving Serde
+//! serialization to perform roughly the same speed as a handwritten serializer
+//! for the specific selection of data structure and data format.
+//!
+//! ### Data formats
+//!
+//! The following is a partial list of data formats that have been implemented
+//! for Serde by the community.
+//!
+//! - [JSON](https://github.com/serde-rs/json), the ubiquitous JavaScript Object
+//!   Notation used by many HTTP APIs.
+//! - [Bincode](https://github.com/TyOverby/bincode), a compact binary format
+//!   used for IPC within the Servo rendering engine.
+//! - [CBOR](https://github.com/pyfisch/cbor), a Concise Binary Object
+//!   Representation designed for small message size without the need for
+//!   version negotiation.
+//! - [YAML](https://github.com/dtolnay/serde-yaml), a popular human-friendly
+//!   configuration language that ain't markup language.
+//! - [MessagePack](https://github.com/3Hren/msgpack-rust), an efficient binary
+//!   format that resembles a compact JSON.
+//! - [TOML](https://github.com/alexcrichton/toml-rs), a minimal configuration
+//!   format used by [Cargo](http://doc.crates.io/manifest.html).
+//! - [Pickle](https://github.com/birkenfeld/serde-pickle), a format common in
+//!   the Python world.
+//! - [Hjson](https://github.com/laktak/hjson-rust), a variant of JSON designed
+//!   to be readable and writable by humans.
+//! - [BSON](https://github.com/zonyitoo/bson-rs), the data storage and network
+//!   transfer format used by MongoDB.
+//! - [URL](https://github.com/nox/serde_urlencoded), the x-www-form-urlencoded
+//!   format.
+//! - [XML](https://github.com/serde-rs/xml), the flexible machine-friendly W3C
+//!   standard. *(deserialization only)*
+//! - [Envy](https://github.com/softprops/envy), a way to deserialize
+//!   environment variables into Rust structs. *(deserialization only)*
+//! - [Redis](https://github.com/OneSignal/serde-redis), deserialize values from
+//!   Redis when using [redis-rs](https://crates.io/crates/redis).
+//!   *(deserialization only)*
+
+#![doc(html_root_url="https://docs.serde.rs")]
+#![cfg_attr(not(feature = "std"), no_std)]
+#![cfg_attr(feature = "unstable", feature(inclusive_range, nonzero, specialization, zero_one))]
+#![cfg_attr(feature = "alloc", feature(alloc))]
+#![cfg_attr(feature = "collections", feature(collections))]
+#![cfg_attr(feature = "cargo-clippy", allow(linkedlist, type_complexity, doc_markdown))]
+#![deny(missing_docs)]
+
+#[cfg(feature = "collections")]
+extern crate collections;
+
+#[cfg(feature = "alloc")]
+extern crate alloc;
+
+#[cfg(feature = "unstable")]
+extern crate core as actual_core;
+
+#[cfg(feature = "std")]
+mod core {
+    pub use std::{ops, hash, fmt, cmp, marker, mem, i8, i16, i32, i64, u8, u16, u32, u64, isize,
+                  usize, f32, f64, char, str, num, slice, iter, cell, default, result, option};
+    #[cfg(feature = "unstable")]
+    pub use actual_core::nonzero;
+}
+
+#[doc(inline)]
+pub use ser::{Serialize, Serializer};
+#[doc(inline)]
+pub use de::{Deserialize, Deserializer};
+
+#[macro_use]
+mod macros;
+
+pub mod bytes;
+pub mod de;
+#[cfg(feature = "std")]
+#[doc(hidden)]
+pub mod iter;
+pub mod ser;
+#[cfg_attr(feature = "std", doc(hidden))]
+pub mod error;
+mod utils;
+
+// Generated code uses these to support no_std. Not public API.
+#[doc(hidden)]
+pub mod export;
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde-0.9.9/src/macros.rs
@@ -0,0 +1,222 @@
+#[cfg(feature = "std")]
+#[doc(hidden)]
+#[macro_export]
+macro_rules! forward_to_deserialize_method {
+    ($func:ident($($arg:ty),*)) => {
+        #[inline]
+        fn $func<__V>(self, $(_: $arg,)* visitor: __V) -> ::std::result::Result<__V::Value, Self::Error>
+            where __V: $crate::de::Visitor
+        {
+            self.deserialize(visitor)
+        }
+    };
+}
+
+#[cfg(not(feature = "std"))]
+#[doc(hidden)]
+#[macro_export]
+macro_rules! forward_to_deserialize_method {
+    ($func:ident($($arg:ty),*)) => {
+        #[inline]
+        fn $func<__V>(self, $(_: $arg,)* visitor: __V) -> ::core::result::Result<__V::Value, Self::Error>
+            where __V: $crate::de::Visitor
+        {
+            self.deserialize(visitor)
+        }
+    };
+}
+
+#[doc(hidden)]
+#[macro_export]
+macro_rules! forward_to_deserialize_helper {
+    (bool) => {
+        forward_to_deserialize_method!{deserialize_bool()}
+    };
+    (u8) => {
+        forward_to_deserialize_method!{deserialize_u8()}
+    };
+    (u16) => {
+        forward_to_deserialize_method!{deserialize_u16()}
+    };
+    (u32) => {
+        forward_to_deserialize_method!{deserialize_u32()}
+    };
+    (u64) => {
+        forward_to_deserialize_method!{deserialize_u64()}
+    };
+    (i8) => {
+        forward_to_deserialize_method!{deserialize_i8()}
+    };
+    (i16) => {
+        forward_to_deserialize_method!{deserialize_i16()}
+    };
+    (i32) => {
+        forward_to_deserialize_method!{deserialize_i32()}
+    };
+    (i64) => {
+        forward_to_deserialize_method!{deserialize_i64()}
+    };
+    (f32) => {
+        forward_to_deserialize_method!{deserialize_f32()}
+    };
+    (f64) => {
+        forward_to_deserialize_method!{deserialize_f64()}
+    };
+    (char) => {
+        forward_to_deserialize_method!{deserialize_char()}
+    };
+    (str) => {
+        forward_to_deserialize_method!{deserialize_str()}
+    };
+    (string) => {
+        forward_to_deserialize_method!{deserialize_string()}
+    };
+    (unit) => {
+        forward_to_deserialize_method!{deserialize_unit()}
+    };
+    (option) => {
+        forward_to_deserialize_method!{deserialize_option()}
+    };
+    (seq) => {
+        forward_to_deserialize_method!{deserialize_seq()}
+    };
+    (seq_fixed_size) => {
+        forward_to_deserialize_method!{deserialize_seq_fixed_size(usize)}
+    };
+    (bytes) => {
+        forward_to_deserialize_method!{deserialize_bytes()}
+    };
+    (byte_buf) => {
+        forward_to_deserialize_method!{deserialize_byte_buf()}
+    };
+    (map) => {
+        forward_to_deserialize_method!{deserialize_map()}
+    };
+    (unit_struct) => {
+        forward_to_deserialize_method!{deserialize_unit_struct(&'static str)}
+    };
+    (newtype_struct) => {
+        forward_to_deserialize_method!{deserialize_newtype_struct(&'static str)}
+    };
+    (tuple_struct) => {
+        forward_to_deserialize_method!{deserialize_tuple_struct(&'static str, usize)}
+    };
+    (struct) => {
+        forward_to_deserialize_method!{deserialize_struct(&'static str, &'static [&'static str])}
+    };
+    (struct_field) => {
+        forward_to_deserialize_method!{deserialize_struct_field()}
+    };
+    (tuple) => {
+        forward_to_deserialize_method!{deserialize_tuple(usize)}
+    };
+    (enum) => {
+        forward_to_deserialize_method!{deserialize_enum(&'static str, &'static [&'static str])}
+    };
+    (ignored_any) => {
+        forward_to_deserialize_method!{deserialize_ignored_any()}
+    };
+}
+
+// Super explicit first paragraph because this shows up at the top level and
+// trips up people who are just looking for basic Serialize / Deserialize
+// documentation.
+//
+/// Helper macro when implementing the `Deserializer` part of a new data format
+/// for Serde.
+///
+/// Some `Deserializer` implementations for self-describing formats do not care
+/// what hint the `Visitor` gives them, they just want to blindly call the
+/// `Visitor` method corresponding to the data they can tell is in the input.
+/// This requires repetitive implementations of all the `Deserializer` trait
+/// methods.
+///
+/// ```rust
+/// # #[macro_use] extern crate serde;
+/// # use serde::de::{value, Deserializer, Visitor};
+/// # pub struct MyDeserializer;
+/// # impl Deserializer for MyDeserializer {
+/// #     type Error = value::Error;
+/// #     fn deserialize<V>(self, _: V) -> Result<V::Value, Self::Error>
+/// #         where V: Visitor
+/// #     { unimplemented!() }
+/// #
+/// #[inline]
+/// fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+///     where V: Visitor
+/// {
+///     self.deserialize(visitor)
+/// }
+/// #     forward_to_deserialize! {
+/// #         u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option
+/// #         seq seq_fixed_size bytes byte_buf map unit_struct newtype_struct
+/// #         tuple_struct struct struct_field tuple enum ignored_any
+/// #     }
+/// # }
+/// # fn main() {}
+/// ```
+///
+/// The `forward_to_deserialize!` macro implements these simple forwarding
+/// methods so that they forward directly to `Deserializer::deserialize`. You
+/// can choose which methods to forward.
+///
+/// ```rust
+/// # #[macro_use] extern crate serde;
+/// # use serde::de::{value, Deserializer, Visitor};
+/// # pub struct MyDeserializer;
+/// impl Deserializer for MyDeserializer {
+/// #   type Error = value::Error;
+///     fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+///         where V: Visitor
+///     {
+///         /* ... */
+/// #       let _ = visitor;
+/// #       unimplemented!()
+///     }
+///
+///     forward_to_deserialize! {
+///         bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option
+///         seq seq_fixed_size bytes byte_buf map unit_struct newtype_struct
+///         tuple_struct struct struct_field tuple enum ignored_any
+///     }
+/// }
+/// # fn main() {}
+/// ```
+#[macro_export]
+macro_rules! forward_to_deserialize {
+    ($($func:ident)*) => {
+        $(forward_to_deserialize_helper!{$func})*
+    };
+}
+
+/// Seralize the `$value` that implements Display as a string,
+/// when that string is statically known to never have more than
+/// a constant `$MAX_LEN` bytes.
+///
+/// Panics if the Display impl tries to write more than `$MAX_LEN` bytes.
+#[cfg(feature = "std")]
+// Not exported
+macro_rules! serialize_display_bounded_length {
+    ($value: expr, $MAX_LEN: expr, $serializer: expr) => {
+        {
+            use std::io::Write;
+            let mut buffer: [u8; $MAX_LEN] = unsafe { ::std::mem::uninitialized() };
+            let remaining_len;
+            {
+                let mut remaining = &mut buffer[..];
+                write!(remaining, "{}", $value).unwrap();
+                remaining_len = remaining.len()
+            }
+            let written_len = buffer.len() - remaining_len;
+            let written = &buffer[..written_len];
+
+            // write! only provides std::fmt::Formatter to Display implementations,
+            // which has methods write_str and write_char but no method to write arbitrary bytes.
+            // Therefore, `written` is well-formed in UTF-8.
+            let written_str = unsafe {
+                ::std::str::from_utf8_unchecked(written)
+            };
+            $serializer.serialize_str(written_str)
+        }
+    }
+}
rename from third_party/rust/serde/src/ser/content.rs
rename to third_party/rust/serde-0.9.9/src/ser/content.rs
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde-0.9.9/src/ser/impls.rs
@@ -0,0 +1,723 @@
+#[cfg(feature = "std")]
+use std::borrow::Cow;
+#[cfg(all(feature = "collections", not(feature = "std")))]
+use collections::borrow::Cow;
+
+#[cfg(feature = "std")]
+use std::collections::{BinaryHeap, BTreeMap, BTreeSet, LinkedList, HashMap, HashSet, VecDeque};
+#[cfg(all(feature = "collections", not(feature = "std")))]
+use collections::{BinaryHeap, BTreeMap, BTreeSet, LinkedList, VecDeque, String, Vec};
+
+#[cfg(feature = "collections")]
+use collections::borrow::ToOwned;
+
+#[cfg(feature = "std")]
+use core::hash::{Hash, BuildHasher};
+#[cfg(feature = "unstable")]
+use core::iter;
+#[cfg(feature = "std")]
+use std::net;
+#[cfg(feature = "unstable")]
+use core::ops;
+#[cfg(feature = "std")]
+use std::path;
+#[cfg(feature = "std")]
+use std::rc::Rc;
+#[cfg(all(feature = "alloc", not(feature = "std")))]
+use alloc::rc::Rc;
+#[cfg(feature = "std")]
+use std::time::Duration;
+
+#[cfg(feature = "std")]
+use std::sync::Arc;
+#[cfg(all(feature = "alloc", not(feature = "std")))]
+use alloc::arc::Arc;
+
+#[cfg(all(feature = "alloc", not(feature = "std")))]
+use alloc::boxed::Box;
+
+use core::marker::PhantomData;
+
+#[cfg(feature = "unstable")]
+use core::nonzero::{NonZero, Zeroable};
+
+use super::{Serialize, SerializeSeq, SerializeTuple, Serializer};
+#[cfg(feature = "std")]
+use super::Error;
+
+///////////////////////////////////////////////////////////////////////////////
+
+macro_rules! impl_visit {
+    ($ty:ty, $method:ident $($cast:tt)*) => {
+        impl Serialize for $ty {
+            #[inline]
+            fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+                where S: Serializer,
+            {
+                serializer.$method(*self $($cast)*)
+            }
+        }
+    }
+}
+
+impl_visit!(bool, serialize_bool);
+impl_visit!(isize, serialize_i64 as i64);
+impl_visit!(i8, serialize_i8);
+impl_visit!(i16, serialize_i16);
+impl_visit!(i32, serialize_i32);
+impl_visit!(i64, serialize_i64);
+impl_visit!(usize, serialize_u64 as u64);
+impl_visit!(u8, serialize_u8);
+impl_visit!(u16, serialize_u16);
+impl_visit!(u32, serialize_u32);
+impl_visit!(u64, serialize_u64);
+impl_visit!(f32, serialize_f32);
+impl_visit!(f64, serialize_f64);
+impl_visit!(char, serialize_char);
+
+///////////////////////////////////////////////////////////////////////////////
+
+impl Serialize for str {
+    #[inline]
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        serializer.serialize_str(self)
+    }
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl Serialize for String {
+    #[inline]
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        (&self[..]).serialize(serializer)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+impl<T> Serialize for Option<T>
+    where T: Serialize
+{
+    #[inline]
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        match *self {
+            Some(ref value) => serializer.serialize_some(value),
+            None => serializer.serialize_none(),
+        }
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+impl<T> Serialize for PhantomData<T> {
+    #[inline]
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        serializer.serialize_unit_struct("PhantomData")
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+macro_rules! array_impls {
+    ($len:expr) => {
+        impl<T> Serialize for [T; $len] where T: Serialize {
+            #[inline]
+            fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+                where S: Serializer,
+            {
+                let mut seq = try!(serializer.serialize_seq_fixed_size($len));
+                for e in self {
+                    try!(seq.serialize_element(e));
+                }
+                seq.end()
+            }
+        }
+    }
+}
+
+array_impls!(0);
+array_impls!(1);
+array_impls!(2);
+array_impls!(3);
+array_impls!(4);
+array_impls!(5);
+array_impls!(6);
+array_impls!(7);
+array_impls!(8);
+array_impls!(9);
+array_impls!(10);
+array_impls!(11);
+array_impls!(12);
+array_impls!(13);
+array_impls!(14);
+array_impls!(15);
+array_impls!(16);
+array_impls!(17);
+array_impls!(18);
+array_impls!(19);
+array_impls!(20);
+array_impls!(21);
+array_impls!(22);
+array_impls!(23);
+array_impls!(24);
+array_impls!(25);
+array_impls!(26);
+array_impls!(27);
+array_impls!(28);
+array_impls!(29);
+array_impls!(30);
+array_impls!(31);
+array_impls!(32);
+
+///////////////////////////////////////////////////////////////////////////////
+
+macro_rules! serialize_seq {
+    () => {
+        #[inline]
+        fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+            where S: Serializer,
+        {
+            serializer.collect_seq(self)
+        }
+    }
+}
+
+impl<T> Serialize for [T]
+    where T: Serialize
+{
+    serialize_seq!();
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<T> Serialize for BinaryHeap<T>
+    where T: Serialize + Ord
+{
+    serialize_seq!();
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<T> Serialize for BTreeSet<T>
+    where T: Serialize + Ord
+{
+    serialize_seq!();
+}
+
+#[cfg(feature = "std")]
+impl<T, H> Serialize for HashSet<T, H>
+    where T: Serialize + Eq + Hash,
+          H: BuildHasher
+{
+    serialize_seq!();
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<T> Serialize for LinkedList<T>
+    where T: Serialize
+{
+    serialize_seq!();
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<T> Serialize for Vec<T>
+    where T: Serialize
+{
+    serialize_seq!();
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<T> Serialize for VecDeque<T>
+    where T: Serialize
+{
+    serialize_seq!();
+}
+
+#[cfg(feature = "unstable")]
+impl<A> Serialize for ops::Range<A>
+    where ops::Range<A>: ExactSizeIterator + iter::Iterator<Item = A> + Clone,
+          A: Serialize
+{
+    #[inline]
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        let mut seq = try!(serializer.serialize_seq(Some(self.len())));
+        for e in self.clone() {
+            try!(seq.serialize_element(&e));
+        }
+        seq.end()
+    }
+}
+
+#[cfg(feature = "unstable")]
+impl<A> Serialize for ops::RangeInclusive<A>
+    where ops::RangeInclusive<A>: ExactSizeIterator + iter::Iterator<Item = A> + Clone,
+          A: Serialize
+{
+    #[inline]
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        let mut seq = try!(serializer.serialize_seq(Some(self.len())));
+        for e in self.clone() {
+            try!(seq.serialize_element(&e));
+        }
+        seq.end()
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+impl Serialize for () {
+    #[inline]
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        serializer.serialize_unit()
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+macro_rules! tuple_impls {
+    ($(
+        $TupleVisitor:ident ($len:expr, $($T:ident),+) {
+            $($state:pat => $idx:tt,)+
+        }
+    )+) => {
+        $(
+            impl<$($T),+> Serialize for ($($T,)+)
+                where $($T: Serialize),+
+            {
+                #[inline]
+                fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+                    where S: Serializer,
+                {
+                    let mut tuple = try!(serializer.serialize_tuple($len));
+                    $(
+                        try!(tuple.serialize_element(&self.$idx));
+                    )+
+                    tuple.end()
+                }
+            }
+        )+
+    }
+}
+
+tuple_impls! {
+    TupleVisitor1 (1, T0) {
+        0 => 0,
+    }
+    TupleVisitor2 (2, T0, T1) {
+        0 => 0,
+        1 => 1,
+    }
+    TupleVisitor3 (3, T0, T1, T2) {
+        0 => 0,
+        1 => 1,
+        2 => 2,
+    }
+    TupleVisitor4 (4, T0, T1, T2, T3) {
+        0 => 0,
+        1 => 1,
+        2 => 2,
+        3 => 3,
+    }
+    TupleVisitor5 (5, T0, T1, T2, T3, T4) {
+        0 => 0,
+        1 => 1,
+        2 => 2,
+        3 => 3,
+        4 => 4,
+    }
+    TupleVisitor6 (6, T0, T1, T2, T3, T4, T5) {
+        0 => 0,
+        1 => 1,
+        2 => 2,
+        3 => 3,
+        4 => 4,
+        5 => 5,
+    }
+    TupleVisitor7 (7, T0, T1, T2, T3, T4, T5, T6) {
+        0 => 0,
+        1 => 1,
+        2 => 2,
+        3 => 3,
+        4 => 4,
+        5 => 5,
+        6 => 6,
+    }
+    TupleVisitor8 (8, T0, T1, T2, T3, T4, T5, T6, T7) {
+        0 => 0,
+        1 => 1,
+        2 => 2,
+        3 => 3,
+        4 => 4,
+        5 => 5,
+        6 => 6,
+        7 => 7,
+    }
+    TupleVisitor9 (9, T0, T1, T2, T3, T4, T5, T6, T7, T8) {
+        0 => 0,
+        1 => 1,
+        2 => 2,
+        3 => 3,
+        4 => 4,
+        5 => 5,
+        6 => 6,
+        7 => 7,
+        8 => 8,
+    }
+    TupleVisitor10 (10, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) {
+        0 => 0,
+        1 => 1,
+        2 => 2,
+        3 => 3,
+        4 => 4,
+        5 => 5,
+        6 => 6,
+        7 => 7,
+        8 => 8,
+        9 => 9,
+    }
+    TupleVisitor11 (11, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) {
+        0 => 0,
+        1 => 1,
+        2 => 2,
+        3 => 3,
+        4 => 4,
+        5 => 5,
+        6 => 6,
+        7 => 7,
+        8 => 8,
+        9 => 9,
+        10 => 10,
+    }
+    TupleVisitor12 (12, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) {
+        0 => 0,
+        1 => 1,
+        2 => 2,
+        3 => 3,
+        4 => 4,
+        5 => 5,
+        6 => 6,
+        7 => 7,
+        8 => 8,
+        9 => 9,
+        10 => 10,
+        11 => 11,
+    }
+    TupleVisitor13 (13, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) {
+        0 => 0,
+        1 => 1,
+        2 => 2,
+        3 => 3,
+        4 => 4,
+        5 => 5,
+        6 => 6,
+        7 => 7,
+        8 => 8,
+        9 => 9,
+        10 => 10,
+        11 => 11,
+        12 => 12,
+    }
+    TupleVisitor14 (14, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) {
+        0 => 0,
+        1 => 1,
+        2 => 2,
+        3 => 3,
+        4 => 4,
+        5 => 5,
+        6 => 6,
+        7 => 7,
+        8 => 8,
+        9 => 9,
+        10 => 10,
+        11 => 11,
+        12 => 12,
+        13 => 13,
+    }
+    TupleVisitor15 (15, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) {
+        0 => 0,
+        1 => 1,
+        2 => 2,
+        3 => 3,
+        4 => 4,
+        5 => 5,
+        6 => 6,
+        7 => 7,
+        8 => 8,
+        9 => 9,
+        10 => 10,
+        11 => 11,
+        12 => 12,
+        13 => 13,
+        14 => 14,
+    }
+    TupleVisitor16 (16, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) {
+        0 => 0,
+        1 => 1,
+        2 => 2,
+        3 => 3,
+        4 => 4,
+        5 => 5,
+        6 => 6,
+        7 => 7,
+        8 => 8,
+        9 => 9,
+        10 => 10,
+        11 => 11,
+        12 => 12,
+        13 => 13,
+        14 => 14,
+        15 => 15,
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+macro_rules! serialize_map {
+    () => {
+        #[inline]
+        fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+            where S: Serializer,
+        {
+            serializer.collect_map(self)
+        }
+    }
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<K, V> Serialize for BTreeMap<K, V>
+    where K: Serialize + Ord,
+          V: Serialize
+{
+    serialize_map!();
+}
+
+#[cfg(feature = "std")]
+impl<K, V, H> Serialize for HashMap<K, V, H>
+    where K: Serialize + Eq + Hash,
+          V: Serialize,
+          H: BuildHasher
+{
+    serialize_map!();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+impl<'a, T: ?Sized> Serialize for &'a T
+    where T: Serialize
+{
+    #[inline]
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        (**self).serialize(serializer)
+    }
+}
+
+impl<'a, T: ?Sized> Serialize for &'a mut T
+    where T: Serialize
+{
+    #[inline]
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        (**self).serialize(serializer)
+    }
+}
+
+#[cfg(any(feature = "std", feature = "alloc"))]
+impl<T: ?Sized> Serialize for Box<T>
+    where T: Serialize
+{
+    #[inline]
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        (**self).serialize(serializer)
+    }
+}
+
+#[cfg(any(feature = "std", feature = "alloc"))]
+impl<T> Serialize for Rc<T>
+    where T: Serialize
+{
+    #[inline]
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        (**self).serialize(serializer)
+    }
+}
+
+#[cfg(any(feature = "std", feature = "alloc"))]
+impl<T> Serialize for Arc<T>
+    where T: Serialize
+{
+    #[inline]
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        (**self).serialize(serializer)
+    }
+}
+
+#[cfg(any(feature = "std", feature = "collections"))]
+impl<'a, T: ?Sized> Serialize for Cow<'a, T>
+    where T: Serialize + ToOwned
+{
+    #[inline]
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        (**self).serialize(serializer)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+impl<T, E> Serialize for Result<T, E>
+    where T: Serialize,
+          E: Serialize
+{
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        match *self {
+            Result::Ok(ref value) => serializer.serialize_newtype_variant("Result", 0, "Ok", value),
+            Result::Err(ref value) => {
+                serializer.serialize_newtype_variant("Result", 1, "Err", value)
+            }
+        }
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#[cfg(feature = "std")]
+impl Serialize for Duration {
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        use super::SerializeStruct;
+        let mut state = try!(serializer.serialize_struct("Duration", 2));
+        try!(state.serialize_field("secs", &self.as_secs()));
+        try!(state.serialize_field("nanos", &self.subsec_nanos()));
+        state.end()
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#[cfg(feature = "std")]
+impl Serialize for net::IpAddr {
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        match *self {
+            net::IpAddr::V4(ref a) => a.serialize(serializer),
+            net::IpAddr::V6(ref a) => a.serialize(serializer),
+        }
+    }
+}
+
+#[cfg(feature = "std")]
+impl Serialize for net::Ipv4Addr {
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        /// "101.102.103.104".len()
+        const MAX_LEN: usize = 15;
+        serialize_display_bounded_length!(self, MAX_LEN, serializer)
+    }
+}
+
+#[cfg(feature = "std")]
+impl Serialize for net::Ipv6Addr {
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        /// "1000:1002:1003:1004:1005:1006:1007:1008".len()
+        const MAX_LEN: usize = 39;
+        serialize_display_bounded_length!(self, MAX_LEN, serializer)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#[cfg(feature = "std")]
+impl Serialize for net::SocketAddr {
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        match *self {
+            net::SocketAddr::V4(ref addr) => addr.serialize(serializer),
+            net::SocketAddr::V6(ref addr) => addr.serialize(serializer),
+        }
+    }
+}
+
+#[cfg(feature = "std")]
+impl Serialize for net::SocketAddrV4 {
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        /// "101.102.103.104:65000".len()
+        const MAX_LEN: usize = 21;
+        serialize_display_bounded_length!(self, MAX_LEN, serializer)
+    }
+}
+
+#[cfg(feature = "std")]
+impl Serialize for net::SocketAddrV6 {
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        /// "[1000:1002:1003:1004:1005:1006:1007:1008]:65000".len()
+        const MAX_LEN: usize = 47;
+        serialize_display_bounded_length!(self, MAX_LEN, serializer)
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+#[cfg(feature = "std")]
+impl Serialize for path::Path {
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        match self.to_str() {
+            Some(s) => s.serialize(serializer),
+            None => Err(Error::custom("path contains invalid UTF-8 characters")),
+        }
+    }
+}
+
+#[cfg(feature = "std")]
+impl Serialize for path::PathBuf {
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        self.as_path().serialize(serializer)
+    }
+}
+
+#[cfg(feature = "unstable")]
+impl<T> Serialize for NonZero<T>
+    where T: Serialize + Zeroable
+{
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+        where S: Serializer
+    {
+        (**self).serialize(serializer)
+    }
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde-0.9.9/src/ser/impossible.rs
@@ -0,0 +1,156 @@
+//! This module contains `Impossible` serializer and its implementations.
+
+use core::marker::PhantomData;
+
+use ser::{self, Serialize, SerializeSeq, SerializeTuple, SerializeTupleStruct,
+          SerializeTupleVariant, SerializeMap, SerializeStruct, SerializeStructVariant};
+
+/// Helper type for implementing a `Serializer` that does not support
+/// serializing one of the compound types.
+///
+/// This type cannot be instantiated, but implements every one of the traits
+/// corresponding to the `Serializer` compound types: `SerializeSeq`,
+/// `SerializeTuple`, `SerializeTupleStruct`, `SerializeTupleVariant`,
+/// `SerializeMap`, `SerializeStruct`, and `SerializeStructVariant`.
+///
+/// ```rust,ignore
+/// impl Serializer for MySerializer {
+///     type Ok = ();
+///     type Error = Error;
+///
+///     type SerializeSeq = Impossible<(), Error>;
+///     /* other associated types */
+///
+///     /// This data format does not support serializing sequences.
+///     fn serialize_seq(self,
+///                      len: Option<usize>)
+///                      -> Result<Self::SerializeSeq, Error> {
+///         // Given Impossible cannot be instantiated, the only
+///         // thing we can do here is to return an error.
+///         Err(...)
+///     }
+///
+///     /* other Serializer methods */
+/// }
+/// ```
+pub struct Impossible<Ok, E> {
+    void: Void,
+    _marker: PhantomData<(Ok, E)>,
+}
+
+enum Void {}
+
+impl<Ok, E> SerializeSeq for Impossible<Ok, E>
+    where E: ser::Error
+{
+    type Ok = Ok;
+    type Error = E;
+
+    fn serialize_element<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), E> {
+        match self.void {}
+    }
+
+    fn end(self) -> Result<Ok, E> {
+        match self.void {}
+    }
+}
+
+impl<Ok, E> SerializeTuple for Impossible<Ok, E>
+    where E: ser::Error
+{
+    type Ok = Ok;
+    type Error = E;
+
+    fn serialize_element<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), E> {
+        match self.void {}
+    }
+
+    fn end(self) -> Result<Ok, E> {
+        match self.void {}
+    }
+}
+
+impl<Ok, E> SerializeTupleStruct for Impossible<Ok, E>
+    where E: ser::Error
+{
+    type Ok = Ok;
+    type Error = E;
+
+    fn serialize_field<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), E> {
+        match self.void {}
+    }
+
+    fn end(self) -> Result<Ok, E> {
+        match self.void {}
+    }
+}
+
+impl<Ok, E> SerializeTupleVariant for Impossible<Ok, E>
+    where E: ser::Error
+{
+    type Ok = Ok;
+    type Error = E;
+
+    fn serialize_field<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), E> {
+        match self.void {}
+    }
+
+    fn end(self) -> Result<Ok, E> {
+        match self.void {}
+    }
+}
+
+impl<Ok, E> SerializeMap for Impossible<Ok, E>
+    where E: ser::Error
+{
+    type Ok = Ok;
+    type Error = E;
+
+    fn serialize_key<T: ?Sized + Serialize>(&mut self, _key: &T) -> Result<(), E> {
+        match self.void {}
+    }
+
+    fn serialize_value<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), E> {
+        match self.void {}
+    }
+
+    fn end(self) -> Result<Ok, E> {
+        match self.void {}
+    }
+}
+
+impl<Ok, E> SerializeStruct for Impossible<Ok, E>
+    where E: ser::Error
+{
+    type Ok = Ok;
+    type Error = E;
+
+    fn serialize_field<T: ?Sized + Serialize>(&mut self,
+                                              _key: &'static str,
+                                              _value: &T)
+                                              -> Result<(), E> {
+        match self.void {}
+    }
+
+    fn end(self) -> Result<Ok, E> {
+        match self.void {}
+    }
+}
+
+impl<Ok, E> SerializeStructVariant for Impossible<Ok, E>
+    where E: ser::Error
+{
+    type Ok = Ok;
+    type Error = E;
+
+    fn serialize_field<T: ?Sized + Serialize>(&mut self,
+                                              _key: &'static str,
+                                              _value: &T)
+                                              -> Result<(), E> {
+        match self.void {}
+    }
+
+    fn end(self) -> Result<Ok, E> {
+        match self.void {}
+    }
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde-0.9.9/src/ser/mod.rs
@@ -0,0 +1,848 @@
+//! Generic data structure serialization framework.
+//!
+//! The two most important traits in this module are `Serialize` and
+//! `Serializer`.
+//!
+//!  - **A type that implements `Serialize` is a data structure** that can be
+//!    serialized to any data format supported by Serde, and conversely
+//!  - **A type that implements `Serializer` is a data format** that can
+//!    serialize any data structure supported by Serde.
+//!
+//! # The Serialize trait
+//!
+//! Serde provides `Serialize` implementations for many Rust primitive and
+//! standard library types. The complete list is below. All of these can be
+//! serialized using Serde out of the box.
+//!
+//! Additionally, Serde provides a procedural macro called `serde_derive` to
+//! automatically generate `Serialize` implementations for structs and enums in
+//! your program. See the [codegen section of the manual][codegen] for how to
+//! use this.
+//!
+//! In rare cases it may be necessary to implement `Serialize` manually for some
+//! type in your program. See the [Implementing `Serialize`][impl-serialize]
+//! section of the manual for more about this.
+//!
+//! Third-party crates may provide `Serialize` implementations for types that
+//! they expose. For example the `linked-hash-map` crate provides a
+//! `LinkedHashMap<K, V>` type that is serializable by Serde because the crate
+//! provides an implementation of `Serialize` for it.
+//!
+//! # The Serializer trait
+//!
+//! `Serializer` implementations are provided by third-party crates, for example
+//! [`serde_json`][serde_json], [`serde_yaml`][serde_yaml] and
+//! [`bincode`][bincode].
+//!
+//! A partial list of well-maintained formats is given on the [Serde
+//! website][data-formats].
+//!
+//! # Implementations of Serialize provided by Serde
+//!
+//!  - **Primitive types**:
+//!    - bool
+//!    - isize, i8, i16, i32, i64
+//!    - usize, u8, u16, u32, u64
+//!    - f32, f64
+//!    - char
+//!    - str
+//!    - &T and &mut T
+//!  - **Compound types**:
+//!    - [T]
+//!    - [T; 0] through [T; 32]
+//!    - tuples up to size 16
+//!  - **Common standard library types**:
+//!    - String
+//!    - Option\<T\>
+//!    - Result\<T, E\>
+//!    - PhantomData\<T\>
+//!  - **Wrapper types**:
+//!    - Box\<T\>
+//!    - Rc\<T\>
+//!    - Arc\<T\>
+//!    - Cow\<'a, T\>
+//!  - **Collection types**:
+//!    - BTreeMap\<K, V\>
+//!    - BTreeSet\<T\>
+//!    - BinaryHeap\<T\>
+//!    - HashMap\<K, V, H\>
+//!    - HashSet\<T, H\>
+//!    - LinkedList\<T\>
+//!    - VecDeque\<T\>
+//!    - Vec\<T\>
+//!    - EnumSet\<T\> (unstable)
+//!    - Range\<T\> (unstable)
+//!    - RangeInclusive\<T\> (unstable)
+//!  - **Miscellaneous standard library types**:
+//!    - Duration
+//!    - Path
+//!    - PathBuf
+//!    - NonZero\<T\> (unstable)
+//!  - **Net types**:
+//!    - IpAddr
+//!    - Ipv4Addr
+//!    - Ipv6Addr
+//!    - SocketAddr
+//!    - SocketAddrV4
+//!    - SocketAddrV6
+//!
+//! [codegen]: https://serde.rs/codegen.html
+//! [impl-serialize]: https://serde.rs/impl-serialize.html
+//! [serde_json]: https://github.com/serde-rs/json
+//! [serde_yaml]: https://github.com/dtolnay/serde-yaml
+//! [bincode]: https://github.com/TyOverby/bincode
+//! [data-formats]: https://serde.rs/#data-formats
+
+#[cfg(feature = "std")]
+use std::error;
+#[cfg(not(feature = "std"))]
+use error;
+
+use core::fmt::Display;
+use core::iter::IntoIterator;
+
+mod impls;
+mod impossible;
+
+// Helpers used by generated code. Not public API.
+#[doc(hidden)]
+pub mod private;
+#[cfg(any(feature = "std", feature = "collections"))]
+mod content;
+
+pub use self::impossible::Impossible;
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// Trait used by `Serialize` implementations to generically construct errors
+/// belonging to the `Serializer` against which they are currently running.
+pub trait Error: Sized + error::Error {
+    /// Raised when a `Serialize` implementation encounters a general error
+    /// while serializing a type.
+    ///
+    /// The message should not be capitalized and should not end with a period.
+    ///
+    /// For example, a filesystem `Path` may refuse to serialize itself if it
+    /// contains invalid UTF-8 data.
+    ///
+    /// ```rust
+    /// # use serde::ser::{Serialize, Serializer, Error};
+    /// # struct Path;
+    /// # impl Path { fn to_str(&self) -> Option<&str> { unimplemented!() } }
+    /// impl Serialize for Path {
+    ///     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+    ///         where S: Serializer
+    ///     {
+    ///         match self.to_str() {
+    ///             Some(s) => s.serialize(serializer),
+    ///             None => Err(Error::custom("path contains invalid UTF-8 characters")),
+    ///         }
+    ///     }
+    /// }
+    /// ```
+    fn custom<T: Display>(msg: T) -> Self;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// A **data structure** that can be serialized into any data format supported
+/// by Serde.
+///
+/// Serde provides `Serialize` implementations for many Rust primitive and
+/// standard library types. The complete list is [here][ser]. All of these can
+/// be serialized using Serde out of the box.
+///
+/// Additionally, Serde provides a procedural macro called `serde_derive` to
+/// automatically generate `Serialize` implementations for structs and enums in
+/// your program. See the [codegen section of the manual][codegen] for how to
+/// use this.
+///
+/// In rare cases it may be necessary to implement `Serialize` manually for some
+/// type in your program. See the [Implementing `Serialize`][impl-serialize]
+/// section of the manual for more about this.
+///
+/// Third-party crates may provide `Serialize` implementations for types that
+/// they expose. For example the `linked-hash-map` crate provides a
+/// `LinkedHashMap<K, V>` type that is serializable by Serde because the crate
+/// provides an implementation of `Serialize` for it.
+///
+/// [ser]: https://docs.serde.rs/serde/ser/index.html
+/// [codegen]: https://serde.rs/codegen.html
+/// [impl-serialize]: https://serde.rs/impl-serialize.html
+pub trait Serialize {
+    /// Serialize this value into the given Serde serializer.
+    ///
+    /// See the [Implementing `Serialize`][impl-serialize] section of the manual
+    /// for more information about how to implement this method.
+    ///
+    /// [impl-serialize]: https://serde.rs/impl-serialize.html
+    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+/// A **data format** that can serialize any data structure supported by Serde.
+///
+/// The role of this trait is to define the serialization half of the Serde data
+/// model, which is a way to categorize every Rust data structure into one of 28
+/// possible types. Each method of the `Serializer` trait corresponds to one of
+/// the types of the data model.
+///
+/// Implementations of `Serialize` map themselves into this data model by
+/// invoking exactly one of the `Serializer` methods.
+///
+/// The types that make up the Serde data model are:
+///
+///  - 12 primitive types:
+///    - bool
+///    - i8, i16, i32, i64
+///    - u8, u16, u32, u64
+///    - f32, f64
+///    - char
+///  - string
+///  - byte array - [u8]
+///  - option
+///    - either none or some value
+///  - unit
+///    - unit is the type of () in Rust
+///  - unit_struct
+///    - for example `struct Unit` or `PhantomData<T>`
+///  - unit_variant
+///    - the `E::A` and `E::B` in `enum E { A, B }`
+///  - newtype_struct
+///    - for example `struct Millimeters(u8)`
+///  - newtype_variant
+///    - the `E::N` in `enum E { N(u8) }`
+///  - seq
+///    - a dynamically sized sequence of values, for example `Vec<T>` or
+///      `HashSet<T>`
+///  - seq_fixed_size
+///    - a statically sized sequence of values for which the size will be known
+///      at deserialization time without looking at the serialized data, for
+///      example `[u64; 10]`
+///  - tuple
+///    - for example `(u8,)` or `(String, u64, Vec<T>)`
+///  - tuple_struct
+///    - for example `struct Rgb(u8, u8, u8)`
+///  - tuple_variant
+///    - the `E::T` in `enum E { T(u8, u8) }`
+///  - map
+///    - for example `BTreeMap<K, V>`
+///  - struct
+///    - a key-value pairing in which the keys will be known at deserialization
+///      time without looking at the serialized data, for example `struct S { r:
+///      u8, g: u8, b: u8 }`
+///  - struct_variant
+///    - the `E::S` in `enum E { S { r: u8, g: u8, b: u8 } }`
+///
+/// Many Serde serializers produce text or binary data as output, for example
+/// JSON or Bincode. This is not a requirement of the `Serializer` trait, and
+/// there are serializers that do not produce text or binary output. One example
+/// is the `serde_json::value::Serializer` (distinct from the main `serde_json`
+/// serializer) that produces a `serde_json::Value` data structure in memory as
+/// output.
+pub trait Serializer: Sized {
+    /// The output type produced by this `Serializer` during successful
+    /// serialization. Most serializers that produce text or binary output
+    /// should set `Ok = ()` and serialize into an `io::Write` or buffer
+    /// contained within the `Serializer` instance. Serializers that build
+    /// in-memory data structures may be simplified by using `Ok` to propagate
+    /// the data structure around.
+    type Ok;
+
+    /// The error type when some error occurs during serialization.
+    type Error: Error;
+
+    /// Type returned from `serialize_seq` and `serialize_seq_fixed_size` for
+    /// serializing the content of the sequence.
+    type SerializeSeq: SerializeSeq<Ok = Self::Ok, Error = Self::Error>;
+
+    /// Type returned from `serialize_tuple` for serializing the content of the
+    /// tuple.
+    type SerializeTuple: SerializeTuple<Ok = Self::Ok, Error = Self::Error>;
+
+    /// Type returned from `serialize_tuple_struct` for serializing the content
+    /// of the tuple struct.
+    type SerializeTupleStruct: SerializeTupleStruct<Ok = Self::Ok, Error = Self::Error>;
+
+    /// Type returned from `serialize_tuple_variant` for serializing the content
+    /// of the tuple variant.
+    type SerializeTupleVariant: SerializeTupleVariant<Ok = Self::Ok, Error = Self::Error>;
+
+    /// Type returned from `serialize_map` for serializing the content of the
+    /// map.
+    type SerializeMap: SerializeMap<Ok = Self::Ok, Error = Self::Error>;
+
+    /// Type returned from `serialize_struct` for serializing the content of the
+    /// struct.
+    type SerializeStruct: SerializeStruct<Ok = Self::Ok, Error = Self::Error>;
+
+    /// Type returned from `serialize_struct_variant` for serializing the
+    /// content of the struct variant.
+    type SerializeStructVariant: SerializeStructVariant<Ok = Self::Ok, Error = Self::Error>;
+
+    /// Serialize a `bool` value.
+    fn serialize_bool(self, v: bool) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize an `i8` value.
+    ///
+    /// If the format does not differentiate between `i8` and `i64`, a
+    /// reasonable implementation would be to cast the value to `i64` and
+    /// forward to `serialize_i64`.
+    fn serialize_i8(self, v: i8) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize an `i16` value.
+    ///
+    /// If the format does not differentiate between `i16` and `i64`, a
+    /// reasonable implementation would be to cast the value to `i64` and
+    /// forward to `serialize_i64`.
+    fn serialize_i16(self, v: i16) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize an `i32` value.
+    ///
+    /// If the format does not differentiate between `i32` and `i64`, a
+    /// reasonable implementation would be to cast the value to `i64` and
+    /// forward to `serialize_i64`.
+    fn serialize_i32(self, v: i32) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize an `i64` value.
+    fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize a `u8` value.
+    ///
+    /// If the format does not differentiate between `u8` and `u64`, a
+    /// reasonable implementation would be to cast the value to `u64` and
+    /// forward to `serialize_u64`.
+    fn serialize_u8(self, v: u8) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize a `u16` value.
+    ///
+    /// If the format does not differentiate between `u16` and `u64`, a
+    /// reasonable implementation would be to cast the value to `u64` and
+    /// forward to `serialize_u64`.
+    fn serialize_u16(self, v: u16) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize a `u32` value.
+    ///
+    /// If the format does not differentiate between `u32` and `u64`, a
+    /// reasonable implementation would be to cast the value to `u64` and
+    /// forward to `serialize_u64`.
+    fn serialize_u32(self, v: u32) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize a `u64` value.
+    fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize an `f32` value.
+    ///
+    /// If the format does not differentiate between `f32` and `f64`, a
+    /// reasonable implementation would be to cast the value to `f64` and
+    /// forward to `serialize_f64`.
+    fn serialize_f32(self, v: f32) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize an `f64` value.
+    fn serialize_f64(self, v: f64) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize a character.
+    ///
+    /// If the format does not support characters, it is reasonable to serialize
+    /// it as a single element `str` or a `u32`.
+    fn serialize_char(self, v: char) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize a `&str`.
+    fn serialize_str(self, value: &str) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize a chunk of raw byte data.
+    ///
+    /// Enables serializers to serialize byte slices more compactly or more
+    /// efficiently than other types of slices. If no efficient implementation
+    /// is available, a reasonable implementation would be to forward to
+    /// `serialize_seq`. If forwarded, the implementation looks usually just
+    /// like this:
+    ///
+    /// ```rust,ignore
+    /// let mut seq = self.serialize_seq(Some(value.len()))?;
+    /// for b in value {
+    ///     seq.serialize_element(b)?;
+    /// }
+    /// seq.end()
+    /// ```
+    fn serialize_bytes(self, value: &[u8]) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize a `None` value.
+    fn serialize_none(self) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize a `Some(T)` value.
+    fn serialize_some<T: ?Sized + Serialize>(self, value: &T) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize a `()` value.
+    fn serialize_unit(self) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize a unit struct like `struct Unit` or `PhantomData<T>`.
+    ///
+    /// A reasonable implementation would be to forward to `serialize_unit`.
+    fn serialize_unit_struct(self, name: &'static str) -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize a unit variant like `E::A` in `enum E { A, B }`.
+    ///
+    /// The `name` is the name of the enum, the `variant_index` is the index of
+    /// this variant within the enum, and the `variant` is the name of the
+    /// variant.
+    ///
+    /// A reasonable implementation would be to forward to `serialize_unit`.
+    ///
+    /// ```rust,ignore
+    /// match *self {
+    ///     E::A => serializer.serialize_unit_variant("E", 0, "A"),
+    ///     E::B => serializer.serialize_unit_variant("E", 1, "B"),
+    /// }
+    /// ```
+    fn serialize_unit_variant(self,
+                              name: &'static str,
+                              variant_index: usize,
+                              variant: &'static str)
+                              -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize a newtype struct like `struct Millimeters(u8)`.
+    ///
+    /// Serializers are encouraged to treat newtype structs as insignificant
+    /// wrappers around the data they contain. A reasonable implementation would
+    /// be to forward to `value.serialize(self)`.
+    ///
+    /// ```rust,ignore
+    /// serializer.serialize_newtype_struct("Millimeters", &self.0)
+    /// ```
+    fn serialize_newtype_struct<T: ?Sized + Serialize>(self,
+                                                       name: &'static str,
+                                                       value: &T)
+                                                       -> Result<Self::Ok, Self::Error>;
+
+    /// Serialize a newtype variant like `E::N` in `enum E { N(u8) }`.
+    ///
+    /// The `name` is the name of the enum, the `variant_index` is the index of
+    /// this variant within the enum, and the `variant` is the name of the
+    /// variant. The `value` is the data contained within this newtype variant.
+    ///
+    /// ```rust,ignore
+    /// match *self {
+    ///     E::N(ref n) => serializer.serialize_newtype_variant("E", 0, "N", n),
+    /// }
+    /// ```
+    fn serialize_newtype_variant<T: ?Sized + Serialize>(self,
+                                                        name: &'static str,
+                                                        variant_index: usize,
+                                                        variant: &'static str,
+                                                        value: &T)
+                                                        -> Result<Self::Ok, Self::Error>;
+
+    /// Begin to serialize a dynamically sized sequence. This call must be
+    /// followed by zero or more calls to `serialize_element`, then a call to
+    /// `end`.
+    ///
+    /// The argument is the number of elements in the sequence, which may or may
+    /// not be computable before the sequence is iterated. Some serializers only
+    /// support sequences whose length is known up front.
+    ///
+    /// ```rust,ignore
+    /// let mut seq = serializer.serialize_seq(Some(self.len()))?;
+    /// for element in self {
+    ///     seq.serialize_element(element)?;
+    /// }
+    /// seq.end()
+    /// ```
+    fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq, Self::Error>;
+
+    /// Begin to serialize a statically sized sequence whose length will be
+    /// known at deserialization time without looking at the serialized data.
+    /// This call must be followed by zero or more calls to `serialize_element`,
+    /// then a call to `end`.
+    ///
+    /// ```rust,ignore
+    /// let mut seq = serializer.serialize_seq_fixed_size(self.len())?;
+    /// for element in self {
+    ///     seq.serialize_element(element)?;
+    /// }
+    /// seq.end()
+    /// ```
+    fn serialize_seq_fixed_size(self, size: usize) -> Result<Self::SerializeSeq, Self::Error>;
+
+    /// Begin to serialize a tuple. This call must be followed by zero or more
+    /// calls to `serialize_field`, then a call to `end`.
+    ///
+    /// ```rust,ignore
+    /// let mut tup = serializer.serialize_tuple(3)?;
+    /// tup.serialize_field(&self.0)?;
+    /// tup.serialize_field(&self.1)?;
+    /// tup.serialize_field(&self.2)?;
+    /// tup.end()
+    /// ```
+    fn serialize_tuple(self, len: usize) -> Result<Self::SerializeTuple, Self::Error>;
+
+    /// Begin to serialize a tuple struct like `struct Rgb(u8, u8, u8)`. This
+    /// call must be followed by zero or more calls to `serialize_field`, then a
+    /// call to `end`.
+    ///
+    /// The `name` is the name of the tuple struct and the `len` is the number
+    /// of data fields that will be serialized.
+    ///
+    /// ```rust,ignore
+    /// let mut ts = serializer.serialize_tuple_struct("Rgb", 3)?;
+    /// ts.serialize_field(&self.0)?;
+    /// ts.serialize_field(&self.1)?;
+    /// ts.serialize_field(&self.2)?;
+    /// ts.end()
+    /// ```
+    fn serialize_tuple_struct(self,
+                              name: &'static str,
+                              len: usize)
+                              -> Result<Self::SerializeTupleStruct, Self::Error>;
+
+    /// Begin to serialize a tuple variant like `E::T` in `enum E { T(u8, u8)
+    /// }`. This call must be followed by zero or more calls to
+    /// `serialize_field`, then a call to `end`.
+    ///
+    /// The `name` is the name of the enum, the `variant_index` is the index of
+    /// this variant within the enum, the `variant` is the name of the variant,
+    /// and the `len` is the number of data fields that will be serialized.
+    ///
+    /// ```rust,ignore
+    /// match *self {
+    ///     E::T(ref a, ref b) => {
+    ///         let mut tv = serializer.serialize_tuple_variant("E", 0, "T", 2)?;
+    ///         tv.serialize_field(a)?;
+    ///         tv.serialize_field(b)?;
+    ///         tv.end()
+    ///     }
+    /// }
+    /// ```
+    fn serialize_tuple_variant(self,
+                               name: &'static str,
+                               variant_index: usize,
+                               variant: &'static str,
+                               len: usize)
+                               -> Result<Self::SerializeTupleVariant, Self::Error>;
+
+    /// Begin to serialize a map. This call must be followed by zero or more
+    /// calls to `serialize_key` and `serialize_value`, then a call to `end`.
+    ///
+    /// The argument is the number of elements in the map, which may or may not
+    /// be computable before the map is iterated. Some serializers only support
+    /// maps whose length is known up front.
+    ///
+    /// ```rust,ignore
+    /// let mut map = serializer.serialize_map(Some(self.len()))?;
+    /// for (k, v) in self {
+    ///     map.serialize_entry(k, v)?;
+    /// }
+    /// map.end()
+    /// ```
+    fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMap, Self::Error>;
+
+    /// Begin to serialize a struct like `struct Rgb { r: u8, g: u8, b: u8 }`.
+    /// This call must be followed by zero or more calls to `serialize_field`,
+    /// then a call to `end`.
+    ///
+    /// The `name` is the name of the struct and the `len` is the number of
+    /// data fields that will be serialized.
+    ///
+    /// ```rust,ignore
+    /// let mut struc = serializer.serialize_struct("Rgb", 3)?;
+    /// struc.serialize_field("r", &self.r)?;
+    /// struc.serialize_field("g", &self.g)?;
+    /// struc.serialize_field("b", &self.b)?;
+    /// struc.end()
+    /// ```
+    fn serialize_struct(self,
+                        name: &'static str,
+                        len: usize)
+                        -> Result<Self::SerializeStruct, Self::Error>;
+
+    /// Begin to serialize a struct variant like `E::S` in `enum E { S { r: u8,
+    /// g: u8, b: u8 } }`. This call must be followed by zero or more calls to
+    /// `serialize_field`, then a call to `end`.
+    ///
+    /// The `name` is the name of the enum, the `variant_index` is the index of
+    /// this variant within the enum, the `variant` is the name of the variant,
+    /// and the `len` is the number of data fields that will be serialized.
+    ///
+    /// ```rust,ignore
+    /// match *self {
+    ///     E::S { ref r, ref g, ref b } => {
+    ///         let mut sv = serializer.serialize_struct_variant("E", 0, "S", 3)?;
+    ///         sv.serialize_field("r", r)?;
+    ///         sv.serialize_field("g", g)?;
+    ///         sv.serialize_field("b", b)?;
+    ///         sv.end()
+    ///     }
+    /// }
+    /// ```
+    fn serialize_struct_variant(self,
+                                name: &'static str,
+                                variant_index: usize,
+                                variant: &'static str,
+                                len: usize)
+                                -> Result<Self::SerializeStructVariant, Self::Error>;
+
+    /// Collect an iterator as a sequence.
+    ///
+    /// The default implementation serializes each item yielded by the iterator
+    /// using `Self::SerializeSeq`. Implementors should not need to override
+    /// this method.
+    fn collect_seq<I>(self, iter: I) -> Result<Self::Ok, Self::Error>
+        where I: IntoIterator,
+              <I as IntoIterator>::Item: Serialize
+    {
+        let iter = iter.into_iter();
+        let mut serializer = try!(self.serialize_seq(iter.len_hint()));
+        for item in iter {
+            try!(serializer.serialize_element(&item));
+        }
+        serializer.end()
+    }
+
+    /// Collect an iterator as a map.
+    ///
+    /// The default implementation serializes each pair yielded by the iterator
+    /// using `Self::SerializeMap`. Implementors should not need to override
+    /// this method.
+    fn collect_map<K, V, I>(self, iter: I) -> Result<Self::Ok, Self::Error>
+        where K: Serialize,
+              V: Serialize,
+              I: IntoIterator<Item = (K, V)>
+    {
+        let iter = iter.into_iter();
+        let mut serializer = try!(self.serialize_map(iter.len_hint()));
+        for (key, value) in iter {
+            try!(serializer.serialize_entry(&key, &value));
+        }
+        serializer.end()
+    }
+}
+
+/// Returned from `Serializer::serialize_seq` and
+/// `Serializer::serialize_seq_fixed_size`.
+///
+/// ```rust,ignore
+/// let mut seq = serializer.serialize_seq(Some(self.len()))?;
+/// for element in self {
+///     seq.serialize_element(element)?;
+/// }
+/// seq.end()
+/// ```
+pub trait SerializeSeq {
+    /// Must match the `Ok` type of our `Serializer`.
+    type Ok;
+
+    /// Must match the `Error` type of our `Serializer`.
+    type Error: Error;
+
+    /// Serialize a sequence element.
+    fn serialize_element<T: ?Sized + Serialize>(&mut self, value: &T) -> Result<(), Self::Error>;
+
+    /// Finish serializing a sequence.
+    fn end(self) -> Result<Self::Ok, Self::Error>;
+}
+
+/// Returned from `Serializer::serialize_tuple`.
+///
+/// ```rust,ignore
+/// let mut tup = serializer.serialize_tuple(3)?;
+/// tup.serialize_field(&self.0)?;
+/// tup.serialize_field(&self.1)?;
+/// tup.serialize_field(&self.2)?;
+/// tup.end()
+/// ```
+pub trait SerializeTuple {
+    /// Must match the `Ok` type of our `Serializer`.
+    type Ok;
+
+    /// Must match the `Error` type of our `Serializer`.
+    type Error: Error;
+
+    /// Serialize a tuple element.
+    fn serialize_element<T: ?Sized + Serialize>(&mut self, value: &T) -> Result<(), Self::Error>;
+
+    /// Finish serializing a tuple.
+    fn end(self) -> Result<Self::Ok, Self::Error>;
+}
+
+/// Returned from `Serializer::serialize_tuple_struct`.
+///
+/// ```rust,ignore
+/// let mut ts = serializer.serialize_tuple_struct("Rgb", 3)?;
+/// ts.serialize_field(&self.0)?;
+/// ts.serialize_field(&self.1)?;
+/// ts.serialize_field(&self.2)?;
+/// ts.end()
+/// ```
+pub trait SerializeTupleStruct {
+    /// Must match the `Ok` type of our `Serializer`.
+    type Ok;
+
+    /// Must match the `Error` type of our `Serializer`.
+    type Error: Error;
+
+    /// Serialize a tuple struct field.
+    fn serialize_field<T: ?Sized + Serialize>(&mut self, value: &T) -> Result<(), Self::Error>;
+
+    /// Finish serializing a tuple struct.
+    fn end(self) -> Result<Self::Ok, Self::Error>;
+}
+
+/// Returned from `Serializer::serialize_tuple_variant`.
+///
+/// ```rust,ignore
+/// match *self {
+///     E::T(ref a, ref b) => {
+///         let mut tv = serializer.serialize_tuple_variant("E", 0, "T", 2)?;
+///         tv.serialize_field(a)?;
+///         tv.serialize_field(b)?;
+///         tv.end()
+///     }
+/// }
+/// ```
+pub trait SerializeTupleVariant {
+    /// Must match the `Ok` type of our `Serializer`.
+    type Ok;
+
+    /// Must match the `Error` type of our `Serializer`.
+    type Error: Error;
+
+    /// Serialize a tuple variant field.
+    fn serialize_field<T: ?Sized + Serialize>(&mut self, value: &T) -> Result<(), Self::Error>;
+
+    /// Finish serializing a tuple variant.
+    fn end(self) -> Result<Self::Ok, Self::Error>;
+}
+
+/// Returned from `Serializer::serialize_map`.
+///
+/// ```rust,ignore
+/// let mut map = serializer.serialize_map(Some(self.len()))?;
+/// for (k, v) in self {
+///     map.serialize_entry(k, v)?;
+/// }
+/// map.end()
+/// ```
+pub trait SerializeMap {
+    /// Must match the `Ok` type of our `Serializer`.
+    type Ok;
+
+    /// Must match the `Error` type of our `Serializer`.
+    type Error: Error;
+
+    /// Serialize a map key.
+    fn serialize_key<T: ?Sized + Serialize>(&mut self, key: &T) -> Result<(), Self::Error>;
+
+    /// Serialize a map value.
+    fn serialize_value<T: ?Sized + Serialize>(&mut self, value: &T) -> Result<(), Self::Error>;
+
+    /// Serialize a map entry consisting of a key and a value.
+    ///
+    /// Some `Serialize` types are not able to hold a key and value in memory at
+    /// the same time so `SerializeMap` implementations are required to support
+    /// `serialize_key` and `serialize_value` individually. The
+    /// `serialize_entry` method allows serializers to optimize for the case
+    /// where key and value are both available. `Serialize` implementations are
+    /// encouraged to use `serialize_entry` if possible.
+    ///
+    /// The default implementation delegates to `serialize_key` and
+    /// `serialize_value`. This is appropriate for serializers that do not care
+    /// about performance or are not able to optimize `serialize_entry` any
+    /// better than this.
+    fn serialize_entry<K: ?Sized + Serialize, V: ?Sized + Serialize>(&mut self,
+                                                                     key: &K,
+                                                                     value: &V)
+                                                                     -> Result<(), Self::Error> {
+        try!(self.serialize_key(key));
+        self.serialize_value(value)
+    }
+
+    /// Finish serializing a map.
+    fn end(self) -> Result<Self::Ok, Self::Error>;
+}
+
+/// Returned from `Serializer::serialize_struct`.
+///
+/// ```rust,ignore
+/// let mut struc = serializer.serialize_struct("Rgb", 3)?;
+/// struc.serialize_field("r", &self.r)?;
+/// struc.serialize_field("g", &self.g)?;
+/// struc.serialize_field("b", &self.b)?;
+/// struc.end()
+/// ```
+pub trait SerializeStruct {
+    /// Must match the `Ok` type of our `Serializer`.
+    type Ok;
+
+    /// Must match the `Error` type of our `Serializer`.
+    type Error: Error;
+
+    /// Serialize a struct field.
+    fn serialize_field<T: ?Sized + Serialize>(&mut self,
+                                              key: &'static str,
+                                              value: &T)
+                                              -> Result<(), Self::Error>;
+
+    /// Finish serializing a struct.
+    fn end(self) -> Result<Self::Ok, Self::Error>;
+}
+
+/// Returned from `Serializer::serialize_struct_variant`.
+///
+/// ```rust,ignore
+/// match *self {
+///     E::S { ref r, ref g, ref b } => {
+///         let mut sv = serializer.serialize_struct_variant("E", 0, "S", 3)?;
+///         sv.serialize_field("r", r)?;
+///         sv.serialize_field("g", g)?;
+///         sv.serialize_field("b", b)?;
+///         sv.end()
+///     }
+/// }
+/// ```
+pub trait SerializeStructVariant {
+    /// Must match the `Ok` type of our `Serializer`.
+    type Ok;
+
+    /// Must match the `Error` type of our `Serializer`.
+    type Error: Error;
+
+    /// Serialize a struct variant field.
+    fn serialize_field<T: ?Sized + Serialize>(&mut self,
+                                              key: &'static str,
+                                              value: &T)
+                                              -> Result<(), Self::Error>;
+
+    /// Finish serializing a struct variant.
+    fn end(self) -> Result<Self::Ok, Self::Error>;
+}
+
+trait LenHint: Iterator {
+    fn len_hint(&self) -> Option<usize>;
+}
+
+impl<I: Iterator> LenHint for I {
+    #[cfg(not(feature = "unstable"))]
+    fn len_hint(&self) -> Option<usize> {
+        iterator_len_hint(self)
+    }
+
+    #[cfg(feature = "unstable")]
+    default fn len_hint(&self) -> Option<usize> {
+        iterator_len_hint(self)
+    }
+}
+
+#[cfg(feature = "unstable")]
+impl<I: ExactSizeIterator> LenHint for I {
+    fn len_hint(&self) -> Option<usize> {
+        Some(self.len())
+    }
+}
+
+fn iterator_len_hint<I: Iterator>(iter: &I) -> Option<usize> {
+    match iter.size_hint() {
+        (lo, Some(hi)) if lo == hi => Some(lo),
+        _ => None,
+    }
+}
rename from third_party/rust/serde/src/ser/private.rs
rename to third_party/rust/serde-0.9.9/src/ser/private.rs
rename from third_party/rust/serde/src/utils.rs
rename to third_party/rust/serde-0.9.9/src/utils.rs
--- a/third_party/rust/serde/.cargo-checksum.json
+++ b/third_party/rust/serde/.cargo-checksum.json
@@ -1,1 +1,1 @@
-{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"e2817af66db5f058a55b5f126ca9a663925bfeb36a592a4121e7e9a44d3a3453","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"ebe318a04cf4e547e0f3ab97f1345ecb553358ee13ea81f99e3323e37d70ccdf","src/bytes.rs":"2b6a9c2c3d6eabe8633adee6655a3b94f0d1e931e740e72699b6965bee21e226","src/de/content.rs":"469d3298d4109d514a8cd630273a288a361544979e2ab23aaa325b2201f9361f","src/de/from_primitive.rs":"b1bd165e343a4380965551709119ef9ed895e4b025045a810dabd671511ba3ab","src/de/impls.rs":"762c3f32627d12555ccd08fcdf3dfb621403c35cde8a5af7866e2ad74c95a4c8","src/de/mod.rs":"365ee7038c53e88cddd451afd11d459f65185fd04523bd000a6b424ac4f71db7","src/de/private.rs":"2578dbc89c2f2a852caed3fdc40f710d4828d085c4e954dd96789d678583424e","src/de/value.rs":"67a34c03fda6521c082548984b0116494e5fbff7e60e30e06f0dda62d9d3e083","src/error.rs":"3af5286c1daad9bfd504693f8a8587f7044c9b9520e23e072549c43a72e4821d","src/export.rs":"0b8e6b642010ad6a71f13f5facfd91e9da1d7c99d479dba020dec10e88fb6b0f","src/iter.rs":"af3c43712c240b3a06870e0b0b6e837b142d5a65c62742fa358fe36a9d9319a7","src/lib.rs":"75df159c150e62c99887c0a4f23ed1271c9eb910ebc79a2d4bd279b0e11ce7e3","src/macros.rs":"af1f75bb34460b814e44f7bc67bdd1dc1bba97f1f2a31744c22e1bfcdc29499a","src/ser/content.rs":"f1cd3724e5ddeacb75b3585b2fd2be7c42fc764444b1f764e31ed9fe49f62025","src/ser/impls.rs":"51d4036b8309381af8267375778bf80c3a9114577c03a04da9a679462077efac","src/ser/impossible.rs":"f1332a1250f9c1d85d679653ade502cf99bdff0344b9f864e6cf1a1789d7c597","src/ser/mod.rs":"d1d821488453651a986bb4e4608f72868c09a71a8dbf693584758b25603ae8bf","src/ser/private.rs":"3999dc19d61d43a64d5d1bdda61f80ea16405a926b074b5441b39d87318be73b","src/utils.rs":"ed271c0825c01d7b24968bf47ce9e2475ca219faf733eb33831d6e19bf07aaf1"},"package":"05a67b8a53f885f4b6e3ed183806035819f9862474e747fe4488a6d63bcbfcb7"}
\ No newline at end of file
+{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"a37a2a8ebf5a7732f77446e1f9fdc6441bf01cc39311c55fa716451fa32ba64d","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"eedee04bddb61e99bc816656bb3b8ae2fa50ff00045ecdb5212682f3592d9ab2","src/de/from_primitive.rs":"28ec3ab1c430cf27d632b642ccfccb6d055eeb9fb576e7e446ba24c66f507fb4","src/de/ignored_any.rs":"1b5ee592f5ae58d69e321144d4397f149c047e327529d0b880e1a5285e781a35","src/de/impls.rs":"8088c7cb2427c9c32bb7104b6d473c9242e98b630b95949543b322348dba4969","src/de/mod.rs":"761d9bd018fe75b8dbd9ec78e2882e533e2488a7cb7980805c1939143eb7a5af","src/de/utf8.rs":"956b124b7ce98353cb781b56e43a6fed2e67f1389d35b7a468d5be75b1485853","src/de/value.rs":"26eec47336c3d31ecbc2b7c131d71954a68ae62b8f13574d85d118eb69177ed1","src/export.rs":"a3e62187f57748cc12109b109cc850343adfab83b74b6b60123fd531c68d5d8d","src/lib.rs":"e2ec21d527103edd1b54d8baa96a44f1c9f7716438214461cd87d606eda64fc0","src/macros.rs":"e1d542b1dac2c1d1f9d5ada7cc5b6639767fc67851421cc3adfb942a7cf750b6","src/private/de.rs":"598f6736d3c23b2e1481932df3636701f36cc5943428647742335081c5c7a650","src/private/macros.rs":"6861a4f332ea24d0ed5db1c28fe3105d2716523902f045c0bbbd439ebf9e44de","src/private/mod.rs":"bcd7c54838e139475c23a323678e20eccbe88c0be93f7977f7675cead4d3b6ed","src/private/ser.rs":"12e686fa3bf7f10ca21642c6308c6ef0b2158ee66ebda412b5d5c388019e7cd7","src/ser/impls.rs":"534f0f94757b0e87304bdbe6f2440b51cb4fc2933d23a62ac61b8c382d80b4c0","src/ser/impossible.rs":"35bd09bb517b28eda0048b0622eb5a0313d5aebf37c03b5a44dbca200d0a9ac8","src/ser/mod.rs":"fc6d1d8dc5e1e1459fda4349634a955c3e59a9bc6d98978be5f8a37bc9c1b02c"},"package":"c0c3d79316a6051231925504f6ef893d45088e8823c77a8331a3dcf427ee9087"}
\ No newline at end of file
--- a/third_party/rust/serde/Cargo.toml
+++ b/third_party/rust/serde/Cargo.toml
@@ -1,34 +1,75 @@
 [package]
 name = "serde"
-version = "0.9.9"
-authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
+version = "1.0.7" # remember to update html_root_url
+authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
 license = "MIT/Apache-2.0"
 description = "A generic serialization/deserialization framework"
 homepage = "https://serde.rs"
 repository = "https://github.com/serde-rs/serde"
 documentation = "https://docs.serde.rs/serde/"
 keywords = ["serde", "serialization", "no_std"]
 categories = ["encoding"]
-readme = "../README.md"
+readme = "README.md"
 include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
 
 [badges]
 travis-ci = { repository = "serde-rs/serde" }
+appveyor = { repository = "serde-rs/serde" }
+
+[dependencies]
+serde_derive = { version = "1.0", optional = true, path = "../serde_derive" }
+
+[dev-dependencies]
+serde_derive = { version = "1.0", path = "../serde_derive" }
+
+
+### FEATURES #################################################################
 
 [features]
 default = ["std"]
 
+# Re-export the derive(Serialize, Deserialize) macros. This is specifically
+# intended for library crates that provide optional Serde impls behind a Cargo
+# cfg of their own. All other crates should depend on serde_derive directly.
+#
+# Please refer to the long comment above the line `pub use serde_derive::*` in
+# src/lib.rs before enabling this feature. If you think you need this feature
+# and your use case does not precisely match the one described in the comment,
+# please open an issue to let us know about your use case.
+derive = ["serde_derive"]
+
+# Provide impls for common standard library types like Vec<T> and HashMap<K, V>.
+# Requires a dependency on the Rust standard library.
 std = []
+
+# Provide impls for types that require unstable functionality. For tracking and
+# discussion of unstable functionality please refer to this issue:
+#
+#    https://github.com/serde-rs/serde/issues/812
 unstable = []
-alloc = ["unstable"]
-collections = ["alloc"]
-unstable-testing = ["unstable", "std"]
 
-# to get serde_derive picked up by play.integer32.com
-playground = ["serde_derive"]
+# Provide impls for types that require memory allocation like Box<T> and Rc<T>.
+# This is a subset of std but may be enabled without depending on all of std.
+#
+# Requires a dependency on the unstable core allocation library:
+#
+#    https://doc.rust-lang.org/alloc/
+alloc = ["unstable"]
 
-[dependencies]
-serde_derive = { version = "0.9", optional = true }
+# Provide impls for collection types like String and Cow<T>. This is a subset of
+# std but may be enabled without depending on all of std.
+#
+# Requires a dependency on the unstable collections library:
+#
+#    https://doc.rust-lang.org/collections/
+collections = ["alloc"]
 
-[dev-dependencies]
-serde_derive = "0.9"
+# Opt into impls for Rc<T> and Arc<T>. Serializing and deserializing these types
+# does not preserve identity and may result in multiple copies of the same data.
+# Be sure that this is what you want before enabling this feature.
+rc = []
+
+# Get serde_derive picked up by the Integer 32 playground. Not public API.
+#
+#    http://play.integer32.com/
+playground = ["serde_derive"]
--- a/third_party/rust/serde/README.md
+++ b/third_party/rust/serde/README.md
@@ -1,29 +1,39 @@
-# Serde &emsp; [![Build Status](https://api.travis-ci.org/serde-rs/serde.svg?branch=master)](https://travis-ci.org/serde-rs/serde) [![Latest Version](https://img.shields.io/crates/v/serde.svg)](https://crates.io/crates/serde)
+# Serde &emsp; [![Build Status]][travis] [![Latest Version]][crates.io]
+
+[Build Status]: https://api.travis-ci.org/serde-rs/serde.svg?branch=master
+[travis]: https://travis-ci.org/serde-rs/serde
+[Latest Version]: https://img.shields.io/crates/v/serde.svg
+[crates.io]: https://crates.io/crates/serde
 
 **Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
 
 ---
 
 You may be looking for:
 
 - [An overview of Serde](https://serde.rs/)
 - [Data formats supported by Serde](https://serde.rs/#data-formats)
 - [Setting up `#[derive(Serialize, Deserialize)]`](https://serde.rs/codegen.html)
 - [Examples](https://serde.rs/examples.html)
 - [API documentation](https://docs.serde.rs/serde/)
 - [Release notes](https://github.com/serde-rs/serde/releases)
 
 ## Serde in action
 
+<a href="http://play.integer32.com/?gist=9003c5b88c1f4989941925d7190c6eec" target="_blank">
+<img align="right" width="50" src="https://raw.githubusercontent.com/serde-rs/serde-rs.github.io/master/img/run.png">
+</a>
+
 ```rust
 #[macro_use]
 extern crate serde_derive;
 
+extern crate serde;
 extern crate serde_json;
 
 #[derive(Serialize, Deserialize, Debug)]
 struct Point {
     x: i32,
     y: i32,
 }
 
--- a/third_party/rust/serde/src/de/from_primitive.rs
+++ b/third_party/rust/serde/src/de/from_primitive.rs
@@ -1,409 +1,116 @@
-// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
+// Copyright 2017 Serde Developers
 //
 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// Extracted from https://github.com/rust-num/num.
-
-// Rust 1.5 is unhappy that this private module is undocumented.
-#![allow(missing_docs)]
-
-use core::{usize, u8, u16, u32, u64};
-use core::{isize, i8, i16, i32, i64};
-use core::{f32, f64};
-use core::mem::size_of;
-
-/// Numbers which have upper and lower bounds
-pub trait Bounded {
-    // FIXME (#5527): These should be associated constants
-    /// returns the smallest finite number this type can represent
-    fn min_value() -> Self;
-    /// returns the largest finite number this type can represent
-    fn max_value() -> Self;
-}
-
-macro_rules! bounded_impl {
-    ($t:ty, $min:expr, $max:expr) => {
-        impl Bounded for $t {
-            #[inline]
-            fn min_value() -> $t { $min }
-
-            #[inline]
-            fn max_value() -> $t { $max }
-        }
-    }
-}
-
-bounded_impl!(usize, usize::MIN, usize::MAX);
-bounded_impl!(u8, u8::MIN, u8::MAX);
-bounded_impl!(u16, u16::MIN, u16::MAX);
-bounded_impl!(u32, u32::MIN, u32::MAX);
-bounded_impl!(u64, u64::MIN, u64::MAX);
-
-bounded_impl!(isize, isize::MIN, isize::MAX);
-bounded_impl!(i8, i8::MIN, i8::MAX);
-bounded_impl!(i16, i16::MIN, i16::MAX);
-bounded_impl!(i32, i32::MIN, i32::MAX);
-bounded_impl!(i64, i64::MIN, i64::MAX);
-
-bounded_impl!(f32, f32::MIN, f32::MAX);
-bounded_impl!(f64, f64::MIN, f64::MAX);
-
-/// A generic trait for converting a value to a number.
-pub trait ToPrimitive {
-    /// Converts the value of `self` to an `isize`.
-    #[inline]
-    fn to_isize(&self) -> Option<isize> {
-        self.to_i64().and_then(|x| x.to_isize())
-    }
-
-    /// Converts the value of `self` to an `i8`.
-    #[inline]
-    fn to_i8(&self) -> Option<i8> {
-        self.to_i64().and_then(|x| x.to_i8())
-    }
-
-    /// Converts the value of `self` to an `i16`.
-    #[inline]
-    fn to_i16(&self) -> Option<i16> {
-        self.to_i64().and_then(|x| x.to_i16())
-    }
+use lib::*;
 
-    /// Converts the value of `self` to an `i32`.
-    #[inline]
-    fn to_i32(&self) -> Option<i32> {
-        self.to_i64().and_then(|x| x.to_i32())
-    }
-
-    /// Converts the value of `self` to an `i64`.
-    fn to_i64(&self) -> Option<i64>;
-
-    /// Converts the value of `self` to a `usize`.
-    #[inline]
-    fn to_usize(&self) -> Option<usize> {
-        self.to_u64().and_then(|x| x.to_usize())
-    }
-
-    /// Converts the value of `self` to an `u8`.
-    #[inline]
-    fn to_u8(&self) -> Option<u8> {
-        self.to_u64().and_then(|x| x.to_u8())
-    }
-
-    /// Converts the value of `self` to an `u16`.
-    #[inline]
-    fn to_u16(&self) -> Option<u16> {
-        self.to_u64().and_then(|x| x.to_u16())
-    }
-
-    /// Converts the value of `self` to an `u32`.
-    #[inline]
-    fn to_u32(&self) -> Option<u32> {
-        self.to_u64().and_then(|x| x.to_u32())
-    }
-
-    /// Converts the value of `self` to an `u64`.
-    #[inline]
-    fn to_u64(&self) -> Option<u64>;
-
-    /// Converts the value of `self` to an `f32`.
-    #[inline]
-    fn to_f32(&self) -> Option<f32> {
-        self.to_f64().and_then(|x| x.to_f32())
-    }
-
-    /// Converts the value of `self` to an `f64`.
-    #[inline]
-    fn to_f64(&self) -> Option<f64> {
-        self.to_i64().and_then(|x| x.to_f64())
-    }
-}
-
-macro_rules! impl_to_primitive_int_to_int {
-    ($SrcT:ty, $DstT:ty, $slf:expr) => (
-        {
-            if size_of::<$SrcT>() <= size_of::<$DstT>() {
-                Some($slf as $DstT)
-            } else {
-                let n = $slf as i64;
-                let min_value: $DstT = Bounded::min_value();
-                let max_value: $DstT = Bounded::max_value();
-                if min_value as i64 <= n && n <= max_value as i64 {
-                    Some($slf as $DstT)
-                } else {
-                    None
-                }
-            }
+macro_rules! int_to_int {
+    ($dst:ident, $n:ident) => (
+        if $dst::MIN as i64 <= $n as i64 && $n as i64 <= $dst::MAX as i64 {
+            Some($n as $dst)
+        } else {
+            None
         }
     )
 }
 
-macro_rules! impl_to_primitive_int_to_uint {
-    ($SrcT:ty, $DstT:ty, $slf:expr) => (
-        {
-            let zero: $SrcT = 0;
-            let max_value: $DstT = Bounded::max_value();
-            if zero <= $slf && $slf as u64 <= max_value as u64 {
-                Some($slf as $DstT)
-            } else {
-                None
-            }
+macro_rules! int_to_uint {
+    ($dst:ident, $n:ident) => (
+        if 0 <= $n && $n as u64 <= $dst::MAX as u64 {
+            Some($n as $dst)
+        } else {
+            None
         }
     )
 }
 
-macro_rules! impl_to_primitive_int {
-    ($T:ty) => (
-        impl ToPrimitive for $T {
-            #[inline]
-            fn to_isize(&self) -> Option<isize> { impl_to_primitive_int_to_int!($T, isize, *self) }
-            #[inline]
-            fn to_i8(&self) -> Option<i8> { impl_to_primitive_int_to_int!($T, i8, *self) }
-            #[inline]
-            fn to_i16(&self) -> Option<i16> { impl_to_primitive_int_to_int!($T, i16, *self) }
-            #[inline]
-            fn to_i32(&self) -> Option<i32> { impl_to_primitive_int_to_int!($T, i32, *self) }
-            #[inline]
-            fn to_i64(&self) -> Option<i64> { impl_to_primitive_int_to_int!($T, i64, *self) }
-
-            #[inline]
-            fn to_usize(&self) -> Option<usize> { impl_to_primitive_int_to_uint!($T, usize, *self) }
-            #[inline]
-            fn to_u8(&self) -> Option<u8> { impl_to_primitive_int_to_uint!($T, u8, *self) }
-            #[inline]
-            fn to_u16(&self) -> Option<u16> { impl_to_primitive_int_to_uint!($T, u16, *self) }
-            #[inline]
-            fn to_u32(&self) -> Option<u32> { impl_to_primitive_int_to_uint!($T, u32, *self) }
-            #[inline]
-            fn to_u64(&self) -> Option<u64> { impl_to_primitive_int_to_uint!($T, u64, *self) }
-
-            #[inline]
-            fn to_f32(&self) -> Option<f32> { Some(*self as f32) }
-            #[inline]
-            fn to_f64(&self) -> Option<f64> { Some(*self as f64) }
+macro_rules! uint_to {
+    ($dst:ident, $n:ident) => (
+        if $n as u64 <= $dst::MAX as u64 {
+            Some($n as $dst)
+        } else {
+            None
         }
     )
 }
 
-impl_to_primitive_int! { isize }
-impl_to_primitive_int! { i8 }
-impl_to_primitive_int! { i16 }
-impl_to_primitive_int! { i32 }
-impl_to_primitive_int! { i64 }
-
-macro_rules! impl_to_primitive_uint_to_int {
-    ($DstT:ty, $slf:expr) => (
-        {
-            let max_value: $DstT = Bounded::max_value();
-            if $slf as u64 <= max_value as u64 {
-                Some($slf as $DstT)
-            } else {
-                None
-            }
-        }
-    )
-}
-
-macro_rules! impl_to_primitive_uint_to_uint {
-    ($SrcT:ty, $DstT:ty, $slf:expr) => (
-        {
-            if size_of::<$SrcT>() <= size_of::<$DstT>() {
-                Some($slf as $DstT)
-            } else {
-                let zero: $SrcT = 0;
-                let max_value: $DstT = Bounded::max_value();
-                if zero <= $slf && $slf as u64 <= max_value as u64 {
-                    Some($slf as $DstT)
-                } else {
-                    None
-                }
-            }
-        }
-    )
+pub trait FromPrimitive: Sized {
+    fn from_isize(n: isize) -> Option<Self>;
+    fn from_i8(n: i8) -> Option<Self>;
+    fn from_i16(n: i16) -> Option<Self>;
+    fn from_i32(n: i32) -> Option<Self>;
+    fn from_i64(n: i64) -> Option<Self>;
+    fn from_usize(n: usize) -> Option<Self>;
+    fn from_u8(n: u8) -> Option<Self>;
+    fn from_u16(n: u16) -> Option<Self>;
+    fn from_u32(n: u32) -> Option<Self>;
+    fn from_u64(n: u64) -> Option<Self>;
 }
 
-macro_rules! impl_to_primitive_uint {
-    ($T:ty) => (
-        impl ToPrimitive for $T {
-            #[inline]
-            fn to_isize(&self) -> Option<isize> { impl_to_primitive_uint_to_int!(isize, *self) }
-            #[inline]
-            fn to_i8(&self) -> Option<i8> { impl_to_primitive_uint_to_int!(i8, *self) }
-            #[inline]
-            fn to_i16(&self) -> Option<i16> { impl_to_primitive_uint_to_int!(i16, *self) }
-            #[inline]
-            fn to_i32(&self) -> Option<i32> { impl_to_primitive_uint_to_int!(i32, *self) }
-            #[inline]
-            fn to_i64(&self) -> Option<i64> { impl_to_primitive_uint_to_int!(i64, *self) }
-
-            #[inline]
-            fn to_usize(&self) -> Option<usize> {
-                impl_to_primitive_uint_to_uint!($T, usize, *self)
-            }
-            #[inline]
-            fn to_u8(&self) -> Option<u8> { impl_to_primitive_uint_to_uint!($T, u8, *self) }
-            #[inline]
-            fn to_u16(&self) -> Option<u16> { impl_to_primitive_uint_to_uint!($T, u16, *self) }
-            #[inline]
-            fn to_u32(&self) -> Option<u32> { impl_to_primitive_uint_to_uint!($T, u32, *self) }
-            #[inline]
-            fn to_u64(&self) -> Option<u64> { impl_to_primitive_uint_to_uint!($T, u64, *self) }
-
-            #[inline]
-            fn to_f32(&self) -> Option<f32> { Some(*self as f32) }
-            #[inline]
-            fn to_f64(&self) -> Option<f64> { Some(*self as f64) }
-        }
-    )
-}
-
-impl_to_primitive_uint! { usize }
-impl_to_primitive_uint! { u8 }
-impl_to_primitive_uint! { u16 }
-impl_to_primitive_uint! { u32 }
-impl_to_primitive_uint! { u64 }
-
-macro_rules! impl_to_primitive_float_to_float {
-    ($SrcT:ident, $DstT:ident, $slf:expr) => (
-        if size_of::<$SrcT>() <= size_of::<$DstT>() {
-            Some($slf as $DstT)
-        } else {
-            let n = $slf as f64;
-            let max_value: $SrcT = ::core::$SrcT::MAX;
-            if -max_value as f64 <= n && n <= max_value as f64 {
-                Some($slf as $DstT)
-            } else {
-                None
-            }
+macro_rules! impl_from_primitive_for_int {
+    ($t:ident) => (
+        impl FromPrimitive for $t {
+            #[inline] fn from_isize(n: isize) -> Option<Self> { int_to_int!($t, n) }
+            #[inline] fn from_i8(n: i8) -> Option<Self> { int_to_int!($t, n) }
+            #[inline] fn from_i16(n: i16) -> Option<Self> { int_to_int!($t, n) }
+            #[inline] fn from_i32(n: i32) -> Option<Self> { int_to_int!($t, n) }
+            #[inline] fn from_i64(n: i64) -> Option<Self> { int_to_int!($t, n) }
+            #[inline] fn from_usize(n: usize) -> Option<Self> { uint_to!($t, n) }
+            #[inline] fn from_u8(n: u8) -> Option<Self> { uint_to!($t, n) }
+            #[inline] fn from_u16(n: u16) -> Option<Self> { uint_to!($t, n) }
+            #[inline] fn from_u32(n: u32) -> Option<Self> { uint_to!($t, n) }
+            #[inline] fn from_u64(n: u64) -> Option<Self> { uint_to!($t, n) }
         }
     )
 }
 
-macro_rules! impl_to_primitive_float {
-    ($T:ident) => (
-        impl ToPrimitive for $T {
-            #[inline]
-            fn to_isize(&self) -> Option<isize> { Some(*self as isize) }
-            #[inline]
-            fn to_i8(&self) -> Option<i8> { Some(*self as i8) }
-            #[inline]
-            fn to_i16(&self) -> Option<i16> { Some(*self as i16) }
-            #[inline]
-            fn to_i32(&self) -> Option<i32> { Some(*self as i32) }
-            #[inline]
-            fn to_i64(&self) -> Option<i64> { Some(*self as i64) }
-
-            #[inline]
-            fn to_usize(&self) -> Option<usize> { Some(*self as usize) }
-            #[inline]
-            fn to_u8(&self) -> Option<u8> { Some(*self as u8) }
-            #[inline]
-            fn to_u16(&self) -> Option<u16> { Some(*self as u16) }
-            #[inline]
-            fn to_u32(&self) -> Option<u32> { Some(*self as u32) }
-            #[inline]
-            fn to_u64(&self) -> Option<u64> { Some(*self as u64) }
-
-            #[inline]
-            fn to_f32(&self) -> Option<f32> { impl_to_primitive_float_to_float!($T, f32, *self) }
-            #[inline]
-            fn to_f64(&self) -> Option<f64> { impl_to_primitive_float_to_float!($T, f64, *self) }
+macro_rules! impl_from_primitive_for_uint {
+    ($t:ident) => (
+        impl FromPrimitive for $t {
+            #[inline] fn from_isize(n: isize) -> Option<Self> { int_to_uint!($t, n) }
+            #[inline] fn from_i8(n: i8) -> Option<Self> { int_to_uint!($t, n) }
+            #[inline] fn from_i16(n: i16) -> Option<Self> { int_to_uint!($t, n) }
+            #[inline] fn from_i32(n: i32) -> Option<Self> { int_to_uint!($t, n) }
+            #[inline] fn from_i64(n: i64) -> Option<Self> { int_to_uint!($t, n) }
+            #[inline] fn from_usize(n: usize) -> Option<Self> { uint_to!($t, n) }
+            #[inline] fn from_u8(n: u8) -> Option<Self> { uint_to!($t, n) }
+            #[inline] fn from_u16(n: u16) -> Option<Self> { uint_to!($t, n) }
+            #[inline] fn from_u32(n: u32) -> Option<Self> { uint_to!($t, n) }
+            #[inline] fn from_u64(n: u64) -> Option<Self> { uint_to!($t, n) }
         }
     )
 }
 
-impl_to_primitive_float! { f32 }
-impl_to_primitive_float! { f64 }
-
-pub trait FromPrimitive: Sized {
-    #[inline]
-    fn from_isize(n: isize) -> Option<Self> {
-        FromPrimitive::from_i64(n as i64)
-    }
-
-    #[inline]
-    fn from_i8(n: i8) -> Option<Self> {
-        FromPrimitive::from_i64(n as i64)
-    }
-
-    #[inline]
-    fn from_i16(n: i16) -> Option<Self> {
-        FromPrimitive::from_i64(n as i64)
-    }
-
-    #[inline]
-    fn from_i32(n: i32) -> Option<Self> {
-        FromPrimitive::from_i64(n as i64)
-    }
-
-    fn from_i64(n: i64) -> Option<Self>;
-
-    #[inline]
-    fn from_usize(n: usize) -> Option<Self> {
-        FromPrimitive::from_u64(n as u64)
-    }
-
-    #[inline]
-    fn from_u8(n: u8) -> Option<Self> {
-        FromPrimitive::from_u64(n as u64)
-    }
-
-    #[inline]
-    fn from_u16(n: u16) -> Option<Self> {
-        FromPrimitive::from_u64(n as u64)
-    }
-
-    #[inline]
-    fn from_u32(n: u32) -> Option<Self> {
-        FromPrimitive::from_u64(n as u64)
-    }
-
-    fn from_u64(n: u64) -> Option<Self>;
-
-    #[inline]
-    fn from_f32(n: f32) -> Option<Self> {
-        FromPrimitive::from_f64(n as f64)
-    }
-
-    #[inline]
-    fn from_f64(n: f64) -> Option<Self> {
-        FromPrimitive::from_i64(n as i64)
-    }
-}
-
-macro_rules! impl_from_primitive {
-    ($T:ty, $to_ty:ident) => (
-        impl FromPrimitive for $T {
-            #[inline] fn from_i8(n: i8) -> Option<$T> { n.$to_ty() }
-            #[inline] fn from_i16(n: i16) -> Option<$T> { n.$to_ty() }
-            #[inline] fn from_i32(n: i32) -> Option<$T> { n.$to_ty() }
-            #[inline] fn from_i64(n: i64) -> Option<$T> { n.$to_ty() }
-
-            #[inline] fn from_u8(n: u8) -> Option<$T> { n.$to_ty() }
-            #[inline] fn from_u16(n: u16) -> Option<$T> { n.$to_ty() }
-            #[inline] fn from_u32(n: u32) -> Option<$T> { n.$to_ty() }
-            #[inline] fn from_u64(n: u64) -> Option<$T> { n.$to_ty() }
-
-            #[inline] fn from_f32(n: f32) -> Option<$T> { n.$to_ty() }
-            #[inline] fn from_f64(n: f64) -> Option<$T> { n.$to_ty() }
+macro_rules! impl_from_primitive_for_float {
+    ($t:ident) => (
+        impl FromPrimitive for $t {
+            #[inline] fn from_isize(n: isize) -> Option<Self> { Some(n as Self) }
+            #[inline] fn from_i8(n: i8) -> Option<Self> { Some(n as Self) }
+            #[inline] fn from_i16(n: i16) -> Option<Self> { Some(n as Self) }
+            #[inline] fn from_i32(n: i32) -> Option<Self> { Some(n as Self) }
+            #[inline] fn from_i64(n: i64) -> Option<Self> { Some(n as Self) }
+            #[inline] fn from_usize(n: usize) -> Option<Self> { Some(n as Self) }
+            #[inline] fn from_u8(n: u8) -> Option<Self> { Some(n as Self) }
+            #[inline] fn from_u16(n: u16) -> Option<Self> { Some(n as Self) }
+            #[inline] fn from_u32(n: u32) -> Option<Self> { Some(n as Self) }
+            #[inline] fn from_u64(n: u64) -> Option<Self> { Some(n as Self) }
         }
     )
 }
 
-impl_from_primitive! { isize, to_isize }
-impl_from_primitive! { i8, to_i8 }
-impl_from_primitive! { i16, to_i16 }
-impl_from_primitive! { i32, to_i32 }
-impl_from_primitive! { i64, to_i64 }
-impl_from_primitive! { usize, to_usize }
-impl_from_primitive! { u8, to_u8 }
-impl_from_primitive! { u16, to_u16 }
-impl_from_primitive! { u32, to_u32 }
-impl_from_primitive! { u64, to_u64 }
-impl_from_primitive! { f32, to_f32 }
-impl_from_primitive! { f64, to_f64 }
+impl_from_primitive_for_int!(isize);
+impl_from_primitive_for_int!(i8);
+impl_from_primitive_for_int!(i16);
+impl_from_primitive_for_int!(i32);
+impl_from_primitive_for_int!(i64);
+impl_from_primitive_for_uint!(usize);
+impl_from_primitive_for_uint!(u8);
+impl_from_primitive_for_uint!(u16);
+impl_from_primitive_for_uint!(u32);
+impl_from_primitive_for_uint!(u64);
+impl_from_primitive_for_float!(f32);
+impl_from_primitive_for_float!(f64);
new file mode 100644
--- /dev/null
+++ b/third_party/rust/serde/src/de/ignored_any.rs
@@ -0,0 +1,215 @@
+// Copyright 2017 Serde Developers
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use lib::*;
+
+use de::{Deserialize, Deserializer, Visitor, SeqAccess, MapAccess, Error};
+
+/// An efficient way of discarding data from a deserializer.
+///
+/// Think of this like `serde_json::Value` in that it can be deserialized from
+/// any type, except that it does not store any information about the data that
+/// gets deserialized.
+///
+/// ```rust
+/// use std::fmt;
+/// use std::marker::PhantomData;
+///
+/// use serde::de::{self, Deserialize, DeserializeSeed, Deserializer, Visitor, SeqAccess, IgnoredAny};
+///
+/// /// A seed that can be used to deserialize only the `n`th element of a sequence
+/// /// while efficiently discarding elements of any type before or after index `n`.
+/// ///
+/// /// For example to deserialize only the element at index 3:
+/// ///
+/// /// ```rust
+/// /// NthElement::new(3).deserialize(deserializer)
+/// /// ```
+/// pub struct NthElement<T> {
+///     n: usize,
+///     marker: PhantomData<T>,
+/// }
+///
+/// impl<T> NthElement<T> {
+///     pub fn new(n: usize) -> Self {
+///         NthElement {
+///             n: n,
+///             marker: PhantomData,
+///         }
+///     }
+/// }
+///
+/// impl<'de, T> Visitor<'de> for NthElement<T>
+///     where T: Deserialize<'de>
+/// {
+///     type Value = T;
+///
+///     fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+///         write!(formatter, "a sequence in which we care about element {}", self.n)
+///     }
+///
+///     fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
+///         where A: SeqAccess<'de>
+///     {
+///         // Skip over the first `n` elements.
+///         for i in 0..self.n {
+///             // It is an error if the sequence ends before we get to element `n`.
+///             if seq.next_element::<IgnoredAny>()?.is_none() {
+///                 return Err(de::Error::invalid_length(i, &self));
+///             }
+///         }
+///
+///         // Deserialize the one we care about.
+///         let nth = match seq.next_element()? {
+///             Some(nth) => nth,
+///             None => {
+///                 return Err(de::Error::invalid_length(self.n, &self));
+///             }
+///         };
+///
+///         // Skip over any remaining elements in the sequence after `n`.
+///         while let Some(IgnoredAny) = seq.next_element()? {
+///             // ignore
+///         }
+///
+///         Ok(nth)
+///     }
+/// }
+///
+/// impl<'de, T> DeserializeSeed<'de> for NthElement<T>
+///     where T: Deserialize<'de>
+/// {
+///     type Value = T;
+///
+///     fn deserialize<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
+///         where D: Deserializer<'de>
+///     {
+///         deserializer.deserialize_seq(self)
+///     }
+/// }
+///
+/// # fn example<'de, D>(deserializer: D) -> Result<(), D::Error>
+/// #     where D: Deserializer<'de>
+/// # {
+/// // Deserialize only the sequence element at index 3 from this deserializer.
+/// // The element at index 3 is required to be a string. Elements before and
+/// // after index 3 are allowed to be of any type.
+/// let s: String = NthElement::new(3).deserialize(deserializer)?;
+/// #     Ok(())
+/// # }
+/// ```
+#[derive(Copy, Clone, Debug, Default)]
+pub struct IgnoredAny;
+
+impl<'de> Visitor<'de> for IgnoredAny {
+    type Value = IgnoredAny;
+
+    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        formatter.write_str("anything at all")
+    }
+
+    #[inline]
+    fn visit_bool<E>(self, x: bool) -> Result<Self::Value, E> {
+        let _ = x;
+        Ok(IgnoredAny)
+    }
+
+    #[inline]
+    fn visit_i64<E>(self, x: i64) -> Result<Self::Value, E> {
+        let _ = x;
+        Ok(IgnoredAny)
+    }
+
+    #[inline]
+    fn visit_u64<E>(self, x: u64) -> Result<Self::Value, E> {
+        let _ = x;
+        Ok(IgnoredAny)
+    }
+
+    #[inline]
+    fn visit_f64<E>(self, x: f64) -> Result<Self::Value, E> {
+        let _ = x;
+        Ok(IgnoredAny)
+    }
+
+    #[inline]
+    fn visit_str<E>(self, s: &str) -> Result<Self::Value, E>
+    where
+        E: Error,
+    {
+        let _ = s;
+        Ok(IgnoredAny)
+    }
+
+    #[inline]
+    fn visit_none<E>(self) -> Result<Self::Value, E> {
+        Ok(IgnoredAny)
+    }
+
+    #[inline]
+    fn visit_some<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
+    where
+        D: Deserializer<'de>,
+    {
+        IgnoredAny::deserialize(deserializer)
+    }
+
+    #[inline]
+    fn visit_newtype_struct<D>(self, deserializer: D) -> Result<Self::Value, D::Error>
+    where
+        D: Deserializer<'de>,
+    {
+        IgnoredAny::deserialize(deserializer)
+    }
+
+    #[inline]
+    fn visit_unit<E>(self) -> Result<Self::Value, E> {
+        Ok(IgnoredAny)
+    }
+
+    #[inline]
+    fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>
+    where
+        A: SeqAccess<'de>,
+    {
+        while let Some(IgnoredAny) = try!(seq.next_element()) {
+            // Gobble
+        }
+        Ok(IgnoredAny)
+    }
+
+    #[inline]
+    fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
+    where
+        A: MapAccess<'de>,
+    {
+        while let Some((IgnoredAny, IgnoredAny)) = try!(map.next_entry()) {
+            // Gobble
+        }
+        Ok(IgnoredAny)
+    }
+
+    #[inline]
+    fn visit_bytes<E>(self, bytes: &[u8]) -> Result<Self::Value, E>
+    where
+        E: Error,
+    {
+        let _ = bytes;
+        Ok(IgnoredAny)
+    }
+}
+
+impl<'de> Deserialize<'de> for IgnoredAny {
+    #[inline]
+    fn deserialize<D>(deserializer: D) -> Result<IgnoredAny, D::Error>
+    where
+        D: Deserializer<'de>,
+    {
+        deserializer.deserialize_ignored_any(IgnoredAny)
+    }
+}
--- a/third_party/rust/serde/src/de/impls.rs
+++ b/third_party/rust/serde/src/de/impls.rs
@@ -1,581 +1,686 @@
-//! This module contains `Deserialize` and `Visitor` implementations.
-
-#[cfg(feature = "std")]
-use std::borrow::Cow;
-#[cfg(all(feature = "collections", not(feature = "std")))]
-use collections::borrow::Cow;
+// Copyright 2017 Serde Developers
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
 
-#[cfg(all(feature = "collections", not(feature = "std")))]
-use collections::{BinaryHeap, BTreeMap, BTreeSet, LinkedList, VecDeque, Vec, String};
+use lib::*;
 
-#[cfg(feature = "std")]
-use std::collections::{HashMap, HashSet, BinaryHeap, BTreeMap, BTreeSet, LinkedList, VecDeque};
-
-#[cfg(feature = "collections")]
-use collections::borrow::ToOwned;
+use de::{Deserialize, Deserializer, EnumAccess, Error, SeqAccess, Unexpected, VariantAccess,
+         Visitor};
 
 #[cfg(any(feature = "std", feature = "collections"))]
-use core::cmp;
-use core::fmt;
-#[cfg(feature = "std")]
-use core::hash::{Hash, BuildHasher};
-use core::marker::PhantomData;
-#[cfg(feature = "std")]
-use std::net;
-#[cfg(feature = "std")]
-use std::path;
-use core::str;
-
-#[cfg(feature = "std")]
-use std::rc::Rc;
-#[cfg(all(feature = "alloc", not(feature = "std")))]
-use alloc::rc::Rc;
+use de::MapAccess;
 
-#[cfg(feature = "std")]
-use std::sync::Arc;
-#[cfg(all(feature = "alloc", not(feature = "std")))]
-use alloc::arc::Arc;
-
-#[cfg(all(feature = "alloc", not(feature = "std")))]
-use alloc::boxed::Box;
-
-#[cfg(feature = "std")]
-use std::time::Duration;
-
-#[cfg(feature = "unstable")]
-use core::nonzero::{NonZero, Zeroable};
-
-#[cfg(feature = "unstable")]
-#[allow(deprecated)] // required for impl Deserialize for NonZero<T>
-use core::num::Zero;
-
-use de::{Deserialize, Deserializer, EnumVisitor, Error, MapVisitor, SeqVisitor, Unexpected,
-         VariantVisitor, Visitor};
 use de::from_primitive::FromPrimitive;
 
-///////////////////////////////////////////////////////////////////////////////
+#[cfg(any(feature = "std", feature = "collections"))]
+use private::de::size_hint;
 
-/// A visitor that produces a `()`.
-pub struct UnitVisitor;
+////////////////////////////////////////////////////////////////////////////////
 
-impl Visitor for UnitVisitor {
+struct UnitVisitor;
+
+impl<'de> Visitor<'de> for UnitVisitor {
     type Value = ();
 
     fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
         formatter.write_str("unit")
     }
 
     fn visit_unit<E>(self) -> Result<(), E>
-        where E: Error
-    {
-        Ok(())
-    }
-
-    fn visit_seq<V>(self, _: V) -> Result<(), V::Error>
-        where V: SeqVisitor
+    where
+        E: Error,
     {
         Ok(())
     }
 }
 
-impl Deserialize for () {
+impl<'de> Deserialize<'de> for () {
     fn deserialize<D>(deserializer: D) -> Result<(), D::Error>
-        where D: Deserializer
+    where
+        D: Deserializer<'de>,
     {
         deserializer.deserialize_unit(UnitVisitor)
     }
 }
 
-///////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
-/// A visitor that produces a `bool`.
-pub struct BoolVisitor;
+struct BoolVisitor;
 
-impl Visitor for BoolVisitor {
+impl<'de> Visitor<'de> for BoolVisitor {
     type Value = bool;
 
     fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
         formatter.write_str("a boolean")
     }
 
     fn visit_bool<E>(self, v: bool) -> Result<bool, E>
-        where E: Error
+    where
+        E: Error,
     {
         Ok(v)
     }
-
-    fn visit_str<E>(self, s: &str) -> Result<bool, E>
-        where E: Error
-    {
-        match s.trim_matches(::utils::Pattern_White_Space) {
-            "true" => Ok(true),
-            "false" => Ok(false),
-            _ => Err(Error::invalid_type(Unexpected::Str(s), &self)),
-        }
-    }
 }
 
-impl Deserialize for bool {
+impl<'de> Deserialize<'de> for bool {
     fn deserialize<D>(deserializer: D) -> Result<bool, D::Error>
-        where D: Deserializer
+    where
+        D: Deserializer<'de>,
     {
         deserializer.deserialize_bool(BoolVisitor)
     }
 }
 
-///////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
-macro_rules! impl_deserialize_num_method {
-    ($ty:ident, $src_ty:ident, $method:ident, $from_method:ident, $group:ident, $group_ty:ident) => {
+macro_rules! visit_integer_method {
+    ($src_ty:ident, $method:ident, $from_method:ident, $group:ident, $group_ty:ident) => {
         #[inline]
-        fn $method<E>(self, v: $src_ty) -> Result<$ty, E>
-            where E: Error,
+        fn $method<E>(self, v: $src_ty) -> Result<Self::Value, E>
+        where
+            E: Error,
         {
             match FromPrimitive::$from_method(v) {
                 Some(v) => Ok(v),
                 None => Err(Error::invalid_value(Unexpected::$group(v as $group_ty), &self)),
             }
         }
     }
 }
 
+macro_rules! visit_float_method {
+    ($src_ty:ident, $method:ident) => {
+        #[inline]
+        fn $method<E>(self, v: $src_ty) -> Result<Self::Value, E>
+        where
+            E: Error,
+        {
+            Ok(v as Self::Value)
+        }
+    }
+}
+
 macro_rules! impl_deserialize_num {
-    ($ty:ident, $method:ident) => {
-        impl Deserialize for $ty {
+    ($ty:ident, $method:ident, $($visit:ident),*) => {
+        impl<'de> Deserialize<'de> for $ty {
             #[inline]
             fn deserialize<D>(deserializer: D) -> Result<$ty, D::Error>
-                where D: Deserializer,
+            where
+                D: Deserializer<'de>,
             {
                 struct PrimitiveVisitor;
 
-                impl Visitor for PrimitiveVisitor {
+                impl<'de> Visitor<'de> for PrimitiveVisitor {
                     type Value = $ty;
 
                     fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
                         formatter.write_str(stringify!($ty))
                     }
 
-                    impl_deserialize_num_method!($ty, i8, visit_i8, from_i8, Signed, i64);
-                    impl_deserialize_num_method!($ty, i16, visit_i16, from_i16, Signed, i64);
-                    impl_deserialize_num_method!($ty, i32, visit_i32, from_i32, Signed, i64);
-                    impl_deserialize_num_method!($ty, i64, visit_i64, from_i64, Signed, i64);
-                    impl_deserialize_num_method!($ty, u8, visit_u8, from_u8, Unsigned, u64);
-                    impl_deserialize_num_method!($ty, u16, visit_u16, from_u16, Unsigned, u64);
-                    impl_deserialize_num_method!($ty, u32, visit_u32, from_u32, Unsigned, u64);
-                    impl_deserialize_num_method!($ty, u64, visit_u64, from_u64, Unsigned, u64);
-                    impl_deserialize_num_method!($ty, f32, visit_f32, from_f32, Float, f64);
-                    impl_deserialize_num_method!($ty, f64, visit_f64, from_f64, Float, f64);
-
-                    #[inline]
-                    fn visit_str<E>(self, s: &str) -> Result<$ty, E>
-                        where E: Error,
-                    {
-                        str::FromStr::from_str(s.trim_matches(::utils::Pattern_White_Space)).or_else(|_| {
-                            Err(Error::invalid_type(Unexpected::Str(s), &self))
-                        })
-                    }
+                    $(
+                        impl_deserialize_num!($visit $ty);
+                    )*
                 }
 
                 deserializer.$method(PrimitiveVisitor)
             }
         }
-    }
+    };
+
+    (integer $ty:ident) => {
+        visit_integer_method!(i8, visit_i8, from_i8, Signed, i64);
+        visit_integer_method!(i16, visit_i16, from_i16, Signed, i64);
+        visit_integer_method!(i32, visit_i32, from_i32, Signed, i64);
+        visit_integer_method!(i64, visit_i64, from_i64, Signed, i64);
+
+        visit_integer_method!(u8, visit_u8, from_u8, Unsigned, u64);
+        visit_integer_method!(u16, visit_u16, from_u16, Unsigned, u64);
+        visit_integer_method!(u32, visit_u32, from_u32, Unsigned, u64);
+        visit_integer_method!(u64, visit_u64, from_u64, Unsigned, u64);
+    };
+
+    (float $ty:ident) => {
+        visit_float_method!(f32, visit_f32);
+        visit_float_method!(f64, visit_f64);
+    };
 }
 
-impl_deserialize_num!(isize, deserialize_i64);
-impl_deserialize_num!(i8, deserialize_i8);
-impl_deserialize_num!(i16, deserialize_i16);
-impl_deserialize_num!(i32, deserialize_i32);
-impl_deserialize_num!(i64, deserialize_i64);
-impl_deserialize_num!(usize, deserialize_u64);
-impl_deserialize_num!(u8, deserialize_u8);
-impl_deserialize_num!(u16, deserialize_u16);
-impl_deserialize_num!(u32, deserialize_u32);
-impl_deserialize_num!(u64, deserialize_u64);
-impl_deserialize_num!(f32, deserialize_f32);
-impl_deserialize_num!(f64, deserialize_f64);
+impl_deserialize_num!(i8, deserialize_i8, integer);
+impl_deserialize_num!(i16, deserialize_i16, integer);
+impl_deserialize_num!(i32, deserialize_i32, integer);
+impl_deserialize_num!(i64, deserialize_i64, integer);
+impl_deserialize_num!(isize, deserialize_i64, integer);
 
-///////////////////////////////////////////////////////////////////////////////
+impl_deserialize_num!(u8, deserialize_u8, integer);
+impl_deserialize_num!(u16, deserialize_u16, integer);
+impl_deserialize_num!(u32, deserialize_u32, integer);
+impl_deserialize_num!(u64, deserialize_u64, integer);
+impl_deserialize_num!(usize, deserialize_u64, integer);
+
+impl_deserialize_num!(f32, deserialize_f32, integer, float);
+impl_deserialize_num!(f64, deserialize_f64, integer, float);
+
+////////////////////////////////////////////////////////////////////////////////
 
 struct CharVisitor;
 
-impl Visitor for CharVisitor {
+impl<'de> Visitor<'de> for CharVisitor {
     type Value = char;
 
     fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
         formatter.write_str("a character")
     }
 
     #[inline]
     fn visit_char<E>(self, v: char) -> Result<char, E>
-        where E: Error
+    where
+        E: Error,
     {
         Ok(v)
     }
 
     #[inline]
     fn visit_str<E>(self, v: &str) -> Result<char, E>
-        where E: Error
+    where
+        E: Error,
     {
         let mut iter = v.chars();
         match (iter.next(), iter.next()) {
             (Some(c), None) => Ok(c),
             _ => Err(Error::invalid_value(Unexpected::Str(v), &self)),
         }
     }
 }
 
-impl Deserialize for char {
+impl<'de> Deserialize<'de> for char {
     #[inline]
     fn deserialize<D>(deserializer: D) -> Result<char, D::Error>
-        where D: Deserializer
+    where
+        D: Deserializer<'de>,
     {
         deserializer.deserialize_char(CharVisitor)
     }
 }
 
-///////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 #[cfg(any(feature = "std", feature = "collections"))]
 struct StringVisitor;
 
 #[cfg(any(feature = "std", feature = "collections"))]
-impl Visitor for StringVisitor {
+impl<'de> Visitor<'de> for StringVisitor {
     type Value = String;
 
     fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
         formatter.write_str("a string")
     }
 
     fn visit_str<E>(self, v: &str) -> Result<String, E>
-        where E: Error
+    where
+        E: Error,
     {
         Ok(v.to_owned())
     }
 
     fn visit_string<E>(self, v: String) -> Result<String, E>
-        where E: Error
+    where
+        E: Error,
     {
         Ok(v)
     }
 
-    fn visit_unit<E>(self) -> Result<String, E>
-        where E: Error
-    {
-        Ok(String::new())
-    }
-
     fn visit_bytes<E>(self, v: &[u8]) -> Result<String, E>
-        where E: Error
+    where
+        E: Error,
     {
         match str::from_utf8(v) {
             Ok(s) => Ok(s.to_owned()),
             Err(_) => Err(Error::invalid_value(Unexpected::Bytes(v), &self)),
         }
     }
 
     fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<String, E>
-        where E: Error
+    where
+        E: Error,
     {
         match String::from_utf8(v) {
             Ok(s) => Ok(s),
-            Err(e) => Err(Error::invalid_value(Unexpected::Bytes(&e.into_bytes()), &self)),
+            Err(e) => Err(Error::invalid_value(Unexpected::Bytes(&e.into_bytes()), &self),),
         }
     }
 }
 
 #[cfg(any(feature = "std", feature = "collections"))]
-impl Deserialize for String {
+impl<'de> Deserialize<'de> for String {
     fn deserialize<D>(deserializer: D) -> Result<String, D::Error>
-        where D: Deserializer
+    where
+        D: Deserializer<'de>,
     {
         deserializer.deserialize_string(StringVisitor)
     }
 }
 
-///////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+
+struct StrVisitor;
+
+impl<'a> Visitor<'a> for StrVisitor {
+    type Value = &'a str;
+
+    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        formatter.write_str("a borrowed string")
+    }
+
+    fn visit_borrowed_str<E>(self, v: &'a str) -> Result<Self::Value, E>
+    where
+        E: Error,
+    {
+        Ok(v) // so easy
+    }
+
+    fn visit_borrowed_bytes<E>(self, v: &'a [u8]) -> Result<Self::Value, E>
+    where
+        E: Error,
+    {
+        str::from_utf8(v).map_err(|_| Error::invalid_value(Unexpected::Bytes(v), &self))
+    }
+}
+
+impl<'de: 'a, 'a> Deserialize<'de> for &'a str {
+    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+    where
+        D: Deserializer<'de>,
+    {
+        deserializer.deserialize_str(StrVisitor)
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+struct BytesVisitor;
+
+impl<'a> Visitor<'a> for BytesVisitor {
+    type Value = &'a [u8];
+
+    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        formatter.write_str("a borrowed byte array")
+    }
+
+    fn visit_borrowed_bytes<E>(self, v: &'a [u8]) -> Result<Self::Value, E>
+    where
+        E: Error,
+    {
+        Ok(v)
+    }
+
+    fn visit_borrowed_str<E>(self, v: &'a str) -> Result<Self::Value, E>
+    where
+        E: Error,
+    {
+        Ok(v.as_bytes())
+    }
+}
+
+impl<'de: 'a, 'a> Deserialize<'de> for &'a [u8] {
+    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+    where
+        D: Deserializer<'de>,
+    {
+        deserializer.deserialize_bytes(BytesVisitor)
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#[cfg(feature = "std")]
+struct CStringVisitor;
+
+#[cfg(feature = "std")]
+impl<'de> Visitor<'de> for CStringVisitor {
+    type Value = CString;
+
+    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+        formatter.write_str("byte array")
+    }
+
+    fn visit_seq<A>(self, mut seq: A) -> Result<CString, A::Error>
+    where
+        A: SeqAccess<'de>,
+    {
+        let len = size_hint::cautious(seq.size_hint());
+        let mut values = Vec::with_capacity(len);
+
+        while let Some(value) = try!(seq.next_element()) {
+            values.push(value);
+        }
+
+        CString::new(values).map_err(Error::custom)
+    }
+
+    fn visit_bytes<E>(self, v: &[u8]) -> Result<CString, E>
+    where
+        E: Error,
+    {
+        CString::new(v).map_err(Error::custom)
+    }
+
+    fn visit_byte_buf<E>(self, v: Vec<u8>) -> Result<CString, E>
+    where
+        E: Error,
+    {
+        CString::new(v).map_err(Error::custom)
+    }
+
+    fn visit_str<E>(self, v: &str) -> Result<CString, E>
+    where
+        E: Error,
+    {
+        CString::new(v).map_err(Error::custom)
+    }
+
+    fn visit_string<E>(self, v: String) -> Result<CString, E>
+    where
+        E: Error,
+    {
+        CString::new(v).map_err(Error::custom)
+    }
+}
+
+#[cfg(feature = "std")]
+impl<'de> Deserialize<'de> for CString {
+    fn deserialize<D>(deserializer: D) -> Result<CString, D::Error>
+    where
+        D: Deserializer<'de>,
+    {
+        deserializer.deserialize_byte_buf(CStringVisitor)
+    }
+}
+
+#[cfg(all(feature = "std", feature = "unstable"))]
+impl<'de> Deserialize<'de> for Box<CStr> {
+    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+    where
+        D: Deserializer<'de>,
+    {
+        CString::deserialize(deserializer).map(CString::into_boxed_c_str)
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
 
 struct OptionVisitor<T> {
     marker: PhantomData<T>,
 }
 
-impl<T: Deserialize> Visitor for OptionVisitor<T> {
+impl<'de, T> Visitor<'de> for OptionVisitor<T>
+where
+    T: Deserialize<'de>,
+{
     type Value = Option<T>;
 
     fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
         formatter.write_str("option")
     }
 
     #[inline]
     fn visit_unit<E>(self) -> Result<Option<T>, E>
-        where E: Error
+    where
+        E: Error,
     {
         Ok(None)
     }
 
     #[inline]
     fn visit_none<E>(self) -> Result<Option<T>, E>
-        where E: Error
+    where
+        E: Error,
     {
         Ok(None)
     }
 
     #[inline]
     fn visit_some<D>(self, deserializer: D) -> Result<Option<T>, D::Error>
-        where D: Deserializer
+    where
+        D: Deserializer<'de>,
     {
-        Ok(Some(try!(Deserialize::deserialize(deserializer))))
+        T::deserialize(deserializer).map(Some)
     }
 }
 
-impl<T> Deserialize for Option<T>
-    where T: Deserialize
+impl<'de, T> Deserialize<'de> for Option<T>
+where
+    T: Deserialize<'de>,
 {
     fn deserialize<D>(deserializer: D) -> Result<Option<T>, D::Error>
-        where D: Deserializer
+    where
+        D: Deserializer<'de>,
     {
         deserializer.deserialize_option(OptionVisitor { marker: PhantomData })
     }
 }
 
-///////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
-/// A visitor that produces a `PhantomData`.
-pub struct PhantomDataVisitor<T> {
+struct PhantomDataVisitor<T> {
     marker: PhantomData<T>,
 }
 
-impl<T> Visitor for PhantomDataVisitor<T> {
+impl<'de, T> Visitor<'de> for PhantomDataVisitor<T> {
     type Value = PhantomData<T>;
 
     fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
         formatter.write_str("unit")
     }
 
     #[inline]
     fn visit_unit<E>(self) -> Result<PhantomData<T>, E>
-        where E: Error
+    where
+        E: Error,
     {
         Ok(PhantomData)
     }
 }
 
-impl<T> Deserialize for PhantomData<T> {
+impl<'de, T> Deserialize<'de> for PhantomData<T> {
     fn deserialize<D>(deserializer: D) -> Result<PhantomData<T>, D::Error>
-        where D: Deserializer
+    where
+        D: Deserializer<'de>,
     {
         let visitor = PhantomDataVisitor { marker: PhantomData };
         deserializer.deserialize_unit_struct("PhantomData", visitor)
     }
 }
 
-///////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
+#[cfg(any(feature = "std", feature = "collections"))]
 macro_rules! seq_impl {
     (
-        $ty:ty,
-        $visitor_ty:ident < $($typaram:ident : $bound1:ident $(+ $bound2:ident)*),* >,
-        $visitor:ident,
+        $ty:ident < T $(: $tbound1:ident $(+ $tbound2:ident)*)* $(, $typaram:ident : $bound1:ident $(+ $bound2:ident)*)* >,
+        $access:ident,
         $ctor:expr,
         $with_capacity:expr,
         $insert:expr
     ) => {
-        /// A visitor that produces a sequence.
-        pub struct $visitor_ty<$($typaram),*> {
-            marker: PhantomData<$ty>,
-        }
-
-        impl<$($typaram),*> $visitor_ty<$($typaram),*>
-            where $($typaram: $bound1 $(+ $bound2)*),*
-        {
-            /// Construct a new sequence visitor.
-            pub fn new() -> Self {
-                $visitor_ty {
-                    marker: PhantomData,
-                }
-            }
-        }
-
-        impl<$($typaram),*> Visitor for $visitor_ty<$($typaram),*>
-            where $($typaram: $bound1 $(+ $bound2)*),*
+        impl<'de, T $(, $typaram)*> Deserialize<'de> for $ty<T $(, $typaram)*>
+        where
+            T: Deserialize<'de> $(+ $tbound1 $(+ $tbound2)*)*,
+            $($typaram: $bound1 $(+ $bound2)*,)*
         {
-            type Value = $ty;
-
-            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
-                formatter.write_str("a sequence")
-            }
-
-            #[inline]
-            fn visit_unit<E>(self) -> Result<$ty, E>
-                where E: Error,
+            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+            where
+                D: Deserializer<'de>,
             {
-                Ok($ctor)
-            }
-
-            #[inline]
-            fn visit_seq<V>(self, mut $visitor: V) -> Result<$ty, V::Error>
-                where V: SeqVisitor,
-            {
-                let mut values = $with_capacity;
-
-                while let Some(value) = try!($visitor.visit()) {
-                    $insert(&mut values, value);
+                struct SeqVisitor<T $(, $typaram)*> {
+                    marker: PhantomData<$ty<T $(, $typaram)*>>,
                 }
 
-                Ok(values)
-            }
-        }
+                impl<'de, T $(, $typaram)*> Visitor<'de> for SeqVisitor<T $(, $typaram)*>
+                where
+                    T: Deserialize<'de> $(+ $tbound1 $(+ $tbound2)*)*,
+                    $($typaram: $bound1 $(+ $bound2)*,)*
+                {
+                    type Value = $ty<T $(, $typaram)*>;
+
+                    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                        formatter.write_str("a sequence")
+                    }
 
-        impl<$($typaram),*> Deserialize for $ty
-            where $($typaram: $bound1 $(+ $bound2)*),*
-        {
-            fn deserialize<D>(deserializer: D) -> Result<$ty, D::Error>
-                where D: Deserializer,
-            {
-                deserializer.deserialize_seq($visitor_ty::new())
+                    #[inline]
+                    fn visit_seq<A>(self, mut $access: A) -> Result<Self::Value, A::Error>
+                    where
+                        A: SeqAccess<'de>,
+                    {
+                        let mut values = $with_capacity;
+
+                        while let Some(value) = try!($access.next_element()) {
+                            $insert(&mut values, value);
+                        }
+
+                        Ok(values)
+                    }
+                }
+
+                let visitor = SeqVisitor { marker: PhantomData };
+                deserializer.deserialize_seq(visitor)
             }
         }
     }
 }
 
 #[cfg(any(feature = "std", feature = "collections"))]
 seq_impl!(
-    BinaryHeap<T>,
-    BinaryHeapVisitor<T: Deserialize + Ord>,
-    visitor,
+    BinaryHeap<T: Ord>,
+    seq,
     BinaryHeap::new(),
-    BinaryHeap::with_capacity(cmp::min(visitor.size_hint().0, 4096)),
+    BinaryHeap::with_capacity(size_hint::cautious(seq.size_hint())),
     BinaryHeap::push);
 
 #[cfg(any(feature = "std", feature = "collections"))]
 seq_impl!(
-    BTreeSet<T>,
-    BTreeSetVisitor<T: Deserialize + Eq + Ord>,
-    visitor,
+    BTreeSet<T: Eq + Ord>,
+    seq,
     BTreeSet::new(),
     BTreeSet::new(),
     BTreeSet::insert);
 
 #[cfg(any(feature = "std", feature = "collections"))]
 seq_impl!(
     LinkedList<T>,
-    LinkedListVisitor<T: Deserialize>,
-    visitor,
+    seq,
     LinkedList::new(),
     LinkedList::new(),
     LinkedList::push_back);
 
 #[cfg(feature = "std")]
 seq_impl!(
-    HashSet<T, S>,
-    HashSetVisitor<T: Deserialize + Eq + Hash,
-                   S: BuildHasher + Default>,
-    visitor,
+    HashSet<T: Eq + Hash, S: BuildHasher + Default>,
+    seq,
     HashSet::with_hasher(S::default()),
-    HashSet::with_capacity_and_hasher(cmp::min(visitor.size_hint().0, 4096), S::default()),
+    HashSet::with_capacity_and_hasher(size_hint::cautious(seq.size_hint()), S::default()),
     HashSet::insert);
 
 #[cfg(any(feature = "std", feature = "collections"))]
 seq_impl!(
     Vec<T>,
-    VecVisitor<T: Deserialize>,
-    visitor,
+    seq,
     Vec::new(),
-    Vec::with_capacity(cmp::min(visitor.size_hint().0, 4096)),
+    Vec::with_capacity(size_hint::cautious(seq.size_hint())),
     Vec::push);
 
 #[cfg(any(feature = "std", feature = "collections"))]
 seq_impl!(
     VecDeque<T>,
-    VecDequeVisitor<T: Deserialize>,
-    visitor,
+    seq,
     VecDeque::new(),
-    VecDeque::with_capacity(cmp::min(visitor.size_hint().0, 4096)),
+    VecDeque::with_capacity(size_hint::cautious(seq.size_hint())),
     VecDeque::push_back);
 
-///////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 struct ArrayVisitor<A> {
     marker: PhantomData<A>,
 }
 
 impl<A> ArrayVisitor<A> {
-    pub fn new() -> Self {
+    fn new() -> Self {
         ArrayVisitor { marker: PhantomData }
     }
 }
 
-impl<T> Visitor for ArrayVisitor<[T; 0]>
-    where T: Deserialize
-{
+impl<'de, T> Visitor<'de> for ArrayVisitor<[T; 0]> {
     type Value = [T; 0];
 
     fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
         formatter.write_str("an empty array")
     }
 
     #[inline]
-    fn visit_unit<E>(self) -> Result<[T; 0], E>
-        where E: Error
-    {
-        Ok([])
-    }
-
-    #[inline]
-    fn visit_seq<V>(self, _: V) -> Result<[T; 0], V::Error>
-        where V: SeqVisitor
+    fn visit_seq<A>(self, _: A) -> Result<[T; 0], A::Error>
+    where
+        A: SeqAccess<'de>,
     {
         Ok([])
     }
 }
 
-impl<T> Deserialize for [T; 0]
-    where T: Deserialize
-{
+// Does not require T: Deserialize<'de>.
+impl<'de, T> Deserialize<'de> for [T; 0] {
     fn deserialize<D>(deserializer: D) -> Result<[T; 0], D::Error>
-        where D: Deserializer
+    where
+        D: Deserializer<'de>,
     {
-        deserializer.deserialize_seq_fixed_size(0, ArrayVisitor::<[T; 0]>::new())
+        deserializer.deserialize_tuple(0, ArrayVisitor::<[T; 0]>::new())
     }
 }
 
 macro_rules! array_impls {
     ($($len:expr => ($($n:tt $name:ident)+))+) => {
         $(
-            impl<T> Visitor for ArrayVisitor<[T; $len]> where T: Deserialize {
+            impl<'de, T> Visitor<'de> for ArrayVisitor<[T; $len]>
+            where
+                T: Deserialize<'de>,
+            {
                 type Value = [T; $len];
 
                 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
                     formatter.write_str(concat!("an array of length ", $len))
                 }
 
                 #[inline]
-                fn visit_seq<V>(self, mut visitor: V) -> Result<[T; $len], V::Error>
-                    where V: SeqVisitor,
+                fn visit_seq<A>(self, mut seq: A) -> Result<[T; $len], A::Error>
+                where
+                    A: SeqAccess<'de>,
                 {
                     $(
-                        let $name = match try!(visitor.visit()) {
+                        let $name = match try!(seq.next_element()) {
                             Some(val) => val,
                             None => return Err(Error::invalid_length($n, &self)),
                         };
                     )+
 
                     Ok([$($name),+])
                 }
             }
 
-            impl<T> Deserialize for [T; $len]
-                where T: Deserialize,
+            impl<'de, T> Deserialize<'de> for [T; $len]
+            where
+                T: Deserialize<'de>,
             {
                 fn deserialize<D>(deserializer: D) -> Result<[T; $len], D::Error>
-                    where D: Deserializer,
+                where
+                    D: Deserializer<'de>,
                 {
-                    deserializer.deserialize_seq_fixed_size($len, ArrayVisitor::<[T; $len]>::new())
+                    deserializer.deserialize_tuple($len, ArrayVisitor::<[T; $len]>::new())
                 }
             }
         )+
     }
 }
 
 array_impls! {
     1 => (0 a)
@@ -607,697 +712,932 @@ array_impls! {
     27 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa)
     28 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa 27 ab)
     29 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa 27 ab 28 ac)
     30 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa 27 ab 28 ac 29 ad)
     31 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa 27 ab 28 ac 29 ad 30 ae)
     32 => (0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20 u 21 v 22 w 23 x 24 y 25 z 26 aa 27 ab 28 ac 29 ad 30 ae 31 af)
 }
 
-///////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 macro_rules! tuple_impls {
-    ($($len:expr => $visitor:ident => ($($n:tt $name:ident)+))+) => {
+    ($($len:tt $visitor:ident => ($($n:tt $name:ident)+))+) => {
         $(
-            /// Construct a tuple visitor.
-            pub struct $visitor<$($name,)+> {
+            struct $visitor<$($name,)+> {
                 marker: PhantomData<($($name,)+)>,
             }
 
-            impl<$($name: Deserialize,)+> $visitor<$($name,)+> {
-                /// Construct a `TupleVisitor*<T>`.
-                pub fn new() -> Self {
+            impl<$($name,)+> $visitor<$($name,)+> {
+                fn new() -> Self {
                     $visitor { marker: PhantomData }
                 }
             }
 
-            impl<$($name: Deserialize),+> Visitor for $visitor<$($name,)+> {
+            impl<'de, $($name: Deserialize<'de>),+> Visitor<'de> for $visitor<$($name,)+> {
                 type Value = ($($name,)+);
 
                 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
                     formatter.write_str(concat!("a tuple of size ", $len))
                 }
 
                 #[inline]
                 #[allow(non_snake_case)]
-                fn visit_seq<V>(self, mut visitor: V) -> Result<($($name,)+), V::Error>
-                    where V: SeqVisitor,
+                fn visit_seq<A>(self, mut seq: A) -> Result<($($name,)+), A::Error>
+                where
+                    A: SeqAccess<'de>,
                 {
                     $(
-                        let $name = match try!(visitor.visit()) {
+                        let $name = match try!(seq.next_element()) {
                             Some(value) => value,
                             None => return Err(Error::invalid_length($n, &self)),
                         };
                     )+
 
                     Ok(($($name,)+))
                 }
             }
 
-            impl<$($name: Deserialize),+> Deserialize for ($($name,)+) {
+            impl<'de, $($name: Deserialize<'de>),+> Deserialize<'de> for ($($name,)+) {
                 #[inline]
                 fn deserialize<D>(deserializer: D) -> Result<($($name,)+), D::Error>
-                    where D: Deserializer,
+                where
+                    D: Deserializer<'de>,
                 {
                     deserializer.deserialize_tuple($len, $visitor::new())
                 }
             }
         )+
     }
 }
 
 tuple_impls! {
-    1 => TupleVisitor1 => (0 T0)
-    2 => TupleVisitor2 => (0 T0 1 T1)
-    3 => TupleVisitor3 => (0 T0 1 T1 2 T2)
-    4 => TupleVisitor4 => (0 T0 1 T1 2 T2 3 T3)
-    5 => TupleVisitor5 => (0 T0 1 T1 2 T2 3 T3 4 T4)
-    6 => TupleVisitor6 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5)
-    7 => TupleVisitor7 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6)
-    8 => TupleVisitor8 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7)
-    9 => TupleVisitor9 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8)
-    10 => TupleVisitor10 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9)
-    11 => TupleVisitor11 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10)
-    12 => TupleVisitor12 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11)
-    13 => TupleVisitor13 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12)
-    14 => TupleVisitor14 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13)
-    15 => TupleVisitor15 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13 14 T14)
-    16 => TupleVisitor16 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13 14 T14 15 T15)
+    1 TupleVisitor1 => (0 T0)
+    2 TupleVisitor2 => (0 T0 1 T1)
+    3 TupleVisitor3 => (0 T0 1 T1 2 T2)
+    4 TupleVisitor4 => (0 T0 1 T1 2 T2 3 T3)
+    5 TupleVisitor5 => (0 T0 1 T1 2 T2 3 T3 4 T4)
+    6 TupleVisitor6 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5)
+    7 TupleVisitor7 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6)
+    8 TupleVisitor8 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7)
+    9 TupleVisitor9 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8)
+    10 TupleVisitor10 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9)
+    11 TupleVisitor11 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10)
+    12 TupleVisitor12 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11)
+    13 TupleVisitor13 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12)
+    14 TupleVisitor14 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13)
+    15 TupleVisitor15 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13 14 T14)
+    16 TupleVisitor16 => (0 T0 1 T1 2 T2 3 T3 4 T4 5 T5 6 T6 7 T7 8 T8 9 T9 10 T10 11 T11 12 T12 13 T13 14 T14 15 T15)
 }
 
-///////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
+#[cfg(any(feature = "std", feature = "collections"))]
 macro_rules! map_impl {
     (
-        $ty:ty,
-        $visitor_ty:ident < $($typaram:ident : $bound1:ident $(+ $bound2:ident)*),* >,
-        $visitor:ident,
+        $ty:ident < K $(: $kbound1:ident $(+ $kbound2:ident)*)*, V $(, $typaram:ident : $bound1:ident $(+ $bound2:ident)*)* >,
+        $access:ident,
         $ctor:expr,
         $with_capacity:expr
     ) => {
-        /// A visitor that produces a map.
-        pub struct $visitor_ty<$($typaram),*> {
-            marker: PhantomData<$ty>,
-        }
-
-        impl<$($typaram),*> $visitor_ty<$($typaram),*>
-            where $($typaram: $bound1 $(+ $bound2)*),*
-        {
-            /// Construct a `MapVisitor*<T>`.
-            pub fn new() -> Self {
-                $visitor_ty {
-                    marker: PhantomData,
-                }
-            }
-        }
-
-        impl<$($typaram),*> Visitor for $visitor_ty<$($typaram),*>
-            where $($typaram: $bound1 $(+ $bound2)*),*
+        impl<'de, K, V $(, $typaram)*> Deserialize<'de> for $ty<K, V $(, $typaram)*>
+        where
+            K: Deserialize<'de> $(+ $kbound1 $(+ $kbound2)*)*,
+            V: Deserialize<'de>,
+            $($typaram: $bound1 $(+ $bound2)*),*
         {
-            type Value = $ty;
-
-            fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
-                formatter.write_str("a map")
-            }
-
-            #[inline]
-            fn visit_unit<E>(self) -> Result<$ty, E>
-                where E: Error,
+            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+            where
+                D: Deserializer<'de>,
             {
-                Ok($ctor)
-            }
-
-            #[inline]
-            fn visit_map<Visitor>(self, mut $visitor: Visitor) -> Result<$ty, Visitor::Error>
-                where Visitor: MapVisitor,
-            {
-                let mut values = $with_capacity;
-
-                while let Some((key, value)) = try!($visitor.visit()) {
-                    values.insert(key, value);
+                struct MapVisitor<K, V $(, $typaram)*> {
+                    marker: PhantomData<$ty<K, V $(, $typaram)*>>,
                 }
 
-                Ok(values)
-            }
-        }
+                impl<'de, K, V $(, $typaram)*> Visitor<'de> for MapVisitor<K, V $(, $typaram)*>
+                where
+                    K: Deserialize<'de> $(+ $kbound1 $(+ $kbound2)*)*,
+                    V: Deserialize<'de>,
+                    $($typaram: $bound1 $(+ $bound2)*),*
+                {
+                    type Value = $ty<K, V $(, $typaram)*>;
+
+                    fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+                        formatter.write_str("a map")
+                    }
 
-        impl<$($typaram),*> Deserialize for $ty
-            where $($typaram: $bound1 $(+ $bound2)*),*
-        {
-            fn deserialize<D>(deserializer: D) -> Result<$ty, D::Error>
-                where D: Deserializer,
-            {
-                deserializer.deserialize_map($visitor_ty::new())
+                    #[inline]
+                    fn visit_map<A>(self, mut $access: A) -> Result<Self::Value, A::Error>
+                    where
+                        A: MapAccess<'de>,
+                    {
+                        let mut values = $with_capacity;
+
+                        while let Some((key, value)) = try!($access.next_entry()) {
+                            values.insert(key, value);
+                        }
+
+                        Ok(values)
+                    }
+                }
+
+                let visitor = MapVisitor { marker: PhantomData };
+                deserializer.deserialize_map(visitor)
             }
         }
     }
 }
 
 #[cfg(any(feature = "std", feature = "collections"))]
 map_impl!(
-    BTreeMap<K, V>,
-    BTreeMapVisitor<K: Deserialize + Ord,
-                    V: Deserialize>,
-    visitor,
+    BTreeMap<K: Ord, V>,
+    map,
     BTreeMap::new(),
     BTreeMap::new());
 
 #[cfg(feature = "std")]
 map_impl!(
-    HashMap<K, V, S>,
-    HashMapVisitor<K: Deserialize + Eq + Hash,
-                   V: Deserialize,
-                   S: BuildHasher + Default>,
-    visitor,
+    HashMap<K: Eq + Hash, V, S: BuildHasher + Default>,
+    map,
     HashMap::with_hasher(S::default()),
-    HashMap::with_capacity_and_hasher(cmp::min(visitor.size_hint().0, 4096), S::default()));
+    HashMap::with_capacity_and_hasher(size_hint::cautious(map.size_hint()), S::default()));
 
-///////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
 
 #[cfg(feature = "std")]
-impl Deserialize for net::IpAddr {
-    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
-        where D: Deserializer
-    {
-        let s = try!(String::deserialize(deserializer));
-        match s.parse() {
-            Ok(s) => Ok(s),
-            Err(err) => Err(D::Error::custom(err)),
-        }
-    }
-}
-
-#[cfg(feature = "std")]
-impl Deserialize for net::Ipv4Addr {
-    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
-        where D: Deserializer
-    {
-        let s = try!(String::deserialize(deserializer));
-        match s.parse() {
-            Ok(s) => Ok(s),
-            Err(err) => Err(D::Error::custom(err)),
+macro_rules! parse_impl {
+    ($ty:ty) => {
+        impl<'de> Deserialize<'de> for $ty {
+            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+            where
+                D: Deserializer<'de>,
+            {
+                let s = try!(String::deserialize(deserializer));
+                s.parse().map_err(Error::custom)
+            }
         }
     }
 }
 
 #[cfg(feature = "std")]
-impl Deserialize for net::Ipv6Addr {
-    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
-        where D: Deserializer
-    {
-        let s = try!(String::deserialize(deserializer));
-        match s.parse() {
-            Ok(s) => Ok(s),
-            Err(err) => Err(D::Error::custom(err)),
-        }
-    }
-}
+parse_impl!(net::IpAddr);
+
+#[cfg(feature = "std")]
+parse_impl!(net::Ipv4Addr);
+
+#[cfg(feature = "std")]
+parse_impl!(net::Ipv6Addr);
 
-///////////////////////////////////////////////////////////////////////////////
+#[cfg(feature = "std")]