diff options
| author | Alexis Beingessner <a.beingessner@gmail.com> | 2014-09-18 17:05:52 -0400 |
|---|---|---|
| committer | Alexis Beingessner <a.beingessner@gmail.com> | 2014-09-24 21:53:58 -0400 |
| commit | fe8a413fc0f5d7d021ec42ac1a4149db662ca92c (patch) | |
| tree | 4b69db548f43514ff30815703f6ad413902efdb7 /src/liburl | |
| parent | 8e58f3088b5c86339f8d2cdbdb37d1c54af08bca (diff) | |
| download | rust-fe8a413fc0f5d7d021ec42ac1a4149db662ca92c.tar.gz rust-fe8a413fc0f5d7d021ec42ac1a4149db662ca92c.zip | |
handling fallout from entry api
Diffstat (limited to 'src/liburl')
| -rw-r--r-- | src/liburl/lib.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/liburl/lib.rs b/src/liburl/lib.rs index b5ffdef22e9..0b227b68ca8 100644 --- a/src/liburl/lib.rs +++ b/src/liburl/lib.rs @@ -23,6 +23,7 @@ #![feature(default_type_params)] use std::collections::HashMap; +use std::collections::hashmap::{Occupied, Vacant}; use std::fmt; use std::from_str::FromStr; use std::hash; @@ -342,8 +343,10 @@ pub fn decode_form_urlencoded(s: &[u8]) key: String, value: String) { if key.len() > 0 && value.len() > 0 { - let values = map.find_or_insert_with(key, |_| vec!()); - values.push(value); + match map.entry(key) { + Vacant(entry) => { entry.set(vec![value]); }, + Occupied(mut entry) => { entry.get_mut().push(value); }, + } } } |
