Skip to content

Commit

Permalink
fix(schema): make all pods optionals.
Browse files Browse the repository at this point in the history
That way, json conversions will always work, which is probably what
we desire (especially when handling server answers).
  • Loading branch information
Byron committed Mar 2, 2015
1 parent 49c2ffb commit ddb48a4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/mako/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,18 @@ def nested_type(nt):
return "Option<%s>" % tn
return tn
try:
is_pod = True
rust_type = TYPE_MAP[t.type]
if t.type == 'array':
rust_type = "%s<%s>" % (rust_type, nested_type(t))
is_pod = False
elif t.type == 'object':
rust_type = "%s<String, %s>" % (rust_type, nested_type(t))
is_pod = False
elif rust_type == USE_FORMAT:
rust_type = TYPE_MAP[t.format]
if is_pod and allow_optionals:
return "Option<%s>" % rust_type
return rust_type
except KeyError as err:
raise AssertionError("%s: Property type '%s' unknown - add new type mapping: %s" % (str(err), t.type, str(t)))
Expand Down

0 comments on commit ddb48a4

Please sign in to comment.