diff options
author | Sam Scott <sam.scott89@gmail.com> | 2017-03-12 14:53:16 -0400 |
---|---|---|
committer | Sam Scott <sam.scott89@gmail.com> | 2017-03-12 14:53:16 -0400 |
commit | 57bfc2e1061da6bf55a1d04ac35e6dbbeebabb69 (patch) | |
tree | 0ceed2cda50ce90f0a3f939c7def55ff7225b3f5 /src | |
parent | 71e1aa802eb26b18e2cea412261d8a589ab7c3fe (diff) |
Add in docs link, clean up examples and querystring consistency.
Diffstat (limited to 'src')
-rw-r--r-- | src/de.rs | 10 | ||||
-rw-r--r-- | src/lib.rs | 8 |
2 files changed, 10 insertions, 8 deletions
@@ -53,7 +53,7 @@ impl Config { // T::deserialize(Deserializer::with_config(self, input.as_bytes())) } } -/// Deserializes a query-string from a `&[u8]`. +/// Deserializes a querystring from a `&[u8]`. /// /// ``` /// # #[macro_use] @@ -84,7 +84,7 @@ pub fn from_bytes<T: de::Deserialize>(input: &[u8]) -> Result<T, Error> { Config::default().from_bytes(input) } -/// Deserializes a query-string from a `&str`. +/// Deserializes a querystring from a `&str`. /// /// ``` /// # #[macro_use] @@ -127,7 +127,7 @@ pub fn from_reader<T, R>(mut reader: R) -> Result<T, Error> from_bytes(&buf) } -/// A deserializer for the query-string format. +/// A deserializer for the querystring format. /// /// Supported top-level outputs are structs and maps. pub struct Deserializer { @@ -376,7 +376,7 @@ impl<I: Iterator<Item = u8>> Parser<I> { }, // Key is "[a..." so parse up to the closing "]" 0x20...0x7e => { - let key = self.parse_key(b']', true).unwrap(); + let key = self.parse_key(b']', true)?; // key.into() // println!("key: {:?}", key); self.parse_map_value(key.into(), node)?; @@ -392,7 +392,7 @@ impl<I: Iterator<Item = u8>> Parser<I> { // This means the key should be a root key // of the form "abc" or "abc[...]" 0x20...0x7e => { - let key = self.parse_key(b'[', false).unwrap(); + let key = self.parse_key(b'[', false)?; self.parse_map_value(key.into(), node)?; self.depth += 1; Ok(true) @@ -22,14 +22,16 @@ //! Serializing/Deserializing is designed to work with maps and structs. //! //! ``` +//! #[macro_use] +//! extern crate serde_derive; +//! extern crate serde_qs as qs; //! -//! -//! #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +//! #[derive(Debug, PartialEq, Deserialize, Serialize)] //! struct Address { //! city: String, //! postcode: String, //! } -//! #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +//! #[derive(Debug, PartialEq, Deserialize, Serialize)] //! struct QueryParams { //! id: u8, //! name: String, |