aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/testbindingiterable.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2016-08-29 00:55:29 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2016-08-30 19:07:19 +0200
commit7dfb336be8dae1e2be9b898c374b6715e2a00ac7 (patch)
tree775fbf5f78d812db39ddfab79c56731262d5aded /components/script/dom/testbindingiterable.rs
parent6e1523f4ae61c16578a462c2e5335cbc95a6ef04 (diff)
downloadservo-7dfb336be8dae1e2be9b898c374b6715e2a00ac7.tar.gz
servo-7dfb336be8dae1e2be9b898c374b6715e2a00ac7.zip
Use Option<T> to return from getters
This removes the cumbersome &mut bool argument and offers overall a more readable code.
Diffstat (limited to 'components/script/dom/testbindingiterable.rs')
-rw-r--r--components/script/dom/testbindingiterable.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/components/script/dom/testbindingiterable.rs b/components/script/dom/testbindingiterable.rs
index 1e462a98531..2ad0df6dbb6 100644
--- a/components/script/dom/testbindingiterable.rs
+++ b/components/script/dom/testbindingiterable.rs
@@ -34,10 +34,8 @@ impl TestBindingIterable {
impl TestBindingIterableMethods for TestBindingIterable {
fn Add(&self, v: DOMString) { self.vals.borrow_mut().push(v); }
fn Length(&self) -> u32 { self.vals.borrow().len() as u32 }
- fn GetItem(&self, n: u32) -> DOMString { self.vals.borrow().get(n as usize).unwrap().clone() }
- fn IndexedGetter(&self, n: u32, found: &mut bool) -> DOMString {
- let s = self.GetItem(n);
- *found = true;
- s
+ fn GetItem(&self, n: u32) -> DOMString { self.IndexedGetter(n).unwrap_or_default() }
+ fn IndexedGetter(&self, n: u32) -> Option<DOMString> {
+ self.vals.borrow().get(n as usize).cloned()
}
}