From ddb48a4303a7a0653898e9eea69b3d358a14fa0c Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 2 Mar 2015 19:23:34 +0100 Subject: [PATCH] fix(schema): make all pods optionals. That way, json conversions will always work, which is probably what we desire (especially when handling server answers). --- src/mako/lib/util.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index 926d55ef23..3ea372689b 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -76,13 +76,18 @@ def to_rust_type(sn, pn, t, allow_optionals=True): 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" % (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)))