diff options
author | Corey Farwell <coreyf@rwell.org> | 2015-08-28 14:02:41 -0400 |
---|---|---|
committer | Corey Farwell <coreyf@rwell.org> | 2015-08-28 16:29:11 -0400 |
commit | b0d2194a4a2700418b719e20cbf5bb24831f1a92 (patch) | |
tree | d9589d666cb6f7d965d63aeaa2beae195d809a76 /components/script/dom/formdata.rs | |
parent | 2ca48ca4047e83e69abf1fad6978de46ef11c3a7 (diff) | |
download | servo-b0d2194a4a2700418b719e20cbf5bb24831f1a92.tar.gz servo-b0d2194a4a2700418b719e20cbf5bb24831f1a92.zip |
Cleanup, refactor FormDataMethods::Get
Diffstat (limited to 'components/script/dom/formdata.rs')
-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 |