diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-08-30 07:00:33 -0600 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-08-30 07:00:33 -0600 |
commit | 89a5e2b3d098fc2afdb95ebcebeb8d7beeebc96a (patch) | |
tree | 44fce438f94ded200ed81c01cbb18ebe25eb045e | |
parent | 67cbda4be35a63222553ca806d475581030bea4e (diff) | |
parent | b0d2194a4a2700418b719e20cbf5bb24831f1a92 (diff) | |
download | servo-89a5e2b3d098fc2afdb95ebcebeb8d7beeebc96a.tar.gz servo-89a5e2b3d098fc2afdb95ebcebeb8d7beeebc96a.zip |
Auto merge of #7433 - frewsxcv:formdata-get, r=nox
Cleanup, refactor FormDataMethods::Get
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7433)
<!-- Reviewable:end -->
-rw-r--r-- | components/script/dom/formdata.rs | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs index 8390430c39e..8631cefbd4a 100644 --- a/components/script/dom/formdata.rs +++ b/components/script/dom/formdata.rs @@ -85,21 +85,14 @@ impl FormDataMethods for FormData { self.data.borrow_mut().remove(&name); } - #[allow(unsafe_code)] // https://xhr.spec.whatwg.org/#dom-formdata-get fn Get(&self, name: DOMString) -> Option<FileOrString> { - // FIXME(https://github.com/rust-lang/rust/issues/23338) - let data = self.data.borrow(); - if data.contains_key(&name) { - match data[&name][0].clone() { - FormDatum::StringData(ref s) => Some(eString(s.clone())), - FormDatum::FileData(ref f) => { - Some(eFile(f.root())) - } - } - } else { - None - } + self.data.borrow() + .get(&name) + .map(|entry| match entry[0] { + FormDatum::StringData(ref s) => eString(s.clone()), + FormDatum::FileData(ref f) => eFile(f.root()), + }) } // https://xhr.spec.whatwg.org/#dom-formdata-has |