mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +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
|
@ -317,17 +317,13 @@ impl HTMLCollectionMethods for HTMLCollection {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-htmlcollection-item
|
||||
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Root<Element>> {
|
||||
let maybe_elem = self.Item(index);
|
||||
*found = maybe_elem.is_some();
|
||||
maybe_elem
|
||||
fn IndexedGetter(&self, index: u32) -> Option<Root<Element>> {
|
||||
self.Item(index)
|
||||
}
|
||||
|
||||
// check-tidy: no specs after this line
|
||||
fn NamedGetter(&self, name: DOMString, found: &mut bool) -> Option<Root<Element>> {
|
||||
let maybe_elem = self.NamedItem(name);
|
||||
*found = maybe_elem.is_some();
|
||||
maybe_elem
|
||||
fn NamedGetter(&self, name: DOMString) -> Option<Root<Element>> {
|
||||
self.NamedItem(name)
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#interface-htmlcollection
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue