mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Use Option<T> to return from getters
This removes the cumbersome &mut bool argument and offers overall a more readable code.
This commit is contained in:
parent
6e1523f4ae
commit
7dfb336be8
22 changed files with 72 additions and 109 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue