diff options
author | Sam Scott <sam.scott89@gmail.com> | 2017-03-12 14:44:44 -0400 |
---|---|---|
committer | Sam Scott <sam.scott89@gmail.com> | 2017-03-12 14:44:44 -0400 |
commit | bccdce1a3ac0dc0646f4ffa9bc0a09ea19ae58a5 (patch) | |
tree | 365d4561f44407720f24ec84690611096807c040 /examples | |
parent | 317b8b17f3e3656cdc64fc6435889d005aa9a8af (diff) |
Run rustfmt on code.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/csv_vectors.rs | 10 | ||||
-rw-r--r-- | examples/introduction.rs | 27 |
2 files changed, 18 insertions, 19 deletions
diff --git a/examples/csv_vectors.rs b/examples/csv_vectors.rs index 95e4398..39e95a1 100644 --- a/examples/csv_vectors.rs +++ b/examples/csv_vectors.rs @@ -19,7 +19,7 @@ fn main() { fn from_csv<D>(deserializer: D) -> Result<Vec<u8>, D::Error> - where D: serde::Deserializer + where D: serde::Deserializer, { deserializer.deserialize_str(CSVVecVisitor) } @@ -30,12 +30,14 @@ struct CSVVecVisitor; impl serde::de::Visitor for CSVVecVisitor { type Value = Vec<u8>; - fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + fn expecting(&self, + formatter: &mut std::fmt::Formatter) + -> std::fmt::Result { write!(formatter, "a str") } fn visit_str<E>(self, s: &str) -> std::result::Result<Self::Value, E> - where E: serde::de::Error + where E: serde::de::Error, { let mut output = Vec::new(); let mut items = csv::Reader::from_string(s); @@ -46,6 +48,4 @@ impl serde::de::Visitor for CSVVecVisitor { Ok(output) } - - } diff --git a/examples/introduction.rs b/examples/introduction.rs index 9d949b4..66283d3 100644 --- a/examples/introduction.rs +++ b/examples/introduction.rs @@ -38,7 +38,7 @@ fn main() { city: "Carrot City".to_string(), postcode: "12345".to_string(), }, - user_ids: vec!(1,2,3,4), + user_ids: vec![1, 2, 3, 4], }; // Naive approach: manually parameters in a map. Painful. @@ -80,19 +80,18 @@ fn main() { let encoded2 = qs::to_string(¶ms).unwrap(); assert_eq!(encoded, encoded2); - // An advantage of `serde_qs` for deserializing, is that it is robust against - // different orderings of inputs: + // An advantage of `serde_qs` for deserializing, is that it is robust + // against different orderings of inputs: - let mut inputs = vec!["id=42", - "name=Acme", - "phone=12345", - "address[city]=Carrot+City", - "address[postcode]=12345", - "user_ids[0]=1", - "user_ids[1]=2", - "user_ids[2]=3", - "user_ids[3]=4" - ]; + let mut inputs = vec!["id=42", + "name=Acme", + "phone=12345", + "address[city]=Carrot+City", + "address[postcode]=12345", + "user_ids[0]=1", + "user_ids[1]=2", + "user_ids[2]=3", + "user_ids[3]=4"]; let mut rng = rand::thread_rng(); for _ in 0..10 { @@ -128,4 +127,4 @@ fn main() { user_ids[512]=4"; let params: QueryParams = qs::from_str(encoded).unwrap(); assert_eq!(params, example_params); -}
\ No newline at end of file +} |