From 57bfc2e1061da6bf55a1d04ac35e6dbbeebabb69 Mon Sep 17 00:00:00 2001 From: Sam Scott Date: Sun, 12 Mar 2017 14:53:16 -0400 Subject: Add in docs link, clean up examples and querystring consistency. --- src/de.rs | 10 +++++----- src/lib.rs | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/de.rs b/src/de.rs index ebc7e5f..b33e07b 100644 --- a/src/de.rs +++ b/src/de.rs @@ -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(input: &[u8]) -> Result { 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(mut reader: R) -> Result 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> Parser { }, // 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> Parser { // 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) diff --git a/src/lib.rs b/src/lib.rs index b647eb5..b14df1b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, -- cgit v1.2.3