mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Use the try macro to initialize dictionaries.
This commit is contained in:
parent
49ff6b2ccc
commit
81eab460b1
1 changed files with 6 additions and 9 deletions
|
@ -4365,11 +4365,9 @@ class CGDictionary(CGThing):
|
|||
def impl(self):
|
||||
d = self.dictionary
|
||||
if d.parent:
|
||||
initParent = ("parent: match %s::%s::new(cx, val) {\n"
|
||||
" Ok(parent) => parent,\n"
|
||||
" Err(_) => return Err(()),\n"
|
||||
"},\n") % (self.makeModuleName(d.parent),
|
||||
self.makeClassName(d.parent))
|
||||
initParent = "parent: try!(%s::%s::new(cx, val)),\n" % (
|
||||
self.makeModuleName(d.parent),
|
||||
self.makeClassName(d.parent))
|
||||
else:
|
||||
initParent = ""
|
||||
|
||||
|
@ -4441,12 +4439,11 @@ class CGDictionary(CGThing):
|
|||
conversion = "Some(%s)" % conversion
|
||||
|
||||
conversion = (
|
||||
"match get_dictionary_property(cx, object, \"%s\") {\n"
|
||||
" Err(()) => return Err(()),\n"
|
||||
" Ok(Some(value)) => {\n"
|
||||
"match try!(get_dictionary_property(cx, object, \"%s\")) {\n"
|
||||
" Some(value) => {\n"
|
||||
"%s\n"
|
||||
" },\n"
|
||||
" Ok(None) => {\n"
|
||||
" None => {\n"
|
||||
"%s\n"
|
||||
" },\n"
|
||||
"}") % (member.identifier.name, indent(conversion), indent(default))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue