Skip to content

Commit

Permalink
Auto merge of #5576 - jagtalon:jag/slashdot-storage, r=jdm
Browse files Browse the repository at this point in the history
Use `and_then` and remove `unwrap` instead of using a `map` as described in #5548 (comment).

Fixes #5548
  • Loading branch information
bors-servo committed Apr 11, 2015
2 parents f017a44 + 6d4afaa commit 9754c4c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/net/storage_task.rs
Expand Up @@ -133,9 +133,9 @@ impl StorageManager {
fn remove_item(&mut self, sender: Sender<Option<DOMString>>, url: Url, storage_type: StorageType, name: DOMString) {
let origin = self.get_origin_as_string(url);
let data = self.select_data_mut(storage_type);
let old_value = data.get_mut(&origin).map(|entry| {
let old_value = data.get_mut(&origin).and_then(|entry| {
entry.remove(&name)
}).unwrap();
});
sender.send(old_value).unwrap();
}

Expand Down
14 changes: 14 additions & 0 deletions tests/content/test_storage.html
@@ -0,0 +1,14 @@
<html>
<head>
<title></title>
<script src="harness.js"></script>
</head>
<body>
<script>
// Delete keys that don't exist in either localStorage
// or sessionStorage.
delete localStorage.a;
delete sessionStorage.a;
</script>
</body>
</html>

0 comments on commit 9754c4c

Please sign in to comment.