diff --git a/src/mako/lib/schema.mako b/src/mako/lib/schema.mako index 8d9a444ce3..6897f54825 100644 --- a/src/mako/lib/schema.mako +++ b/src/mako/lib/schema.mako @@ -7,7 +7,6 @@ ################################################################################################################### <%def name="new(s, c)">\ <% - assert s.type == "object" markers = schema_markers(s, c) %>\ <%block filter="rust_doc_comment">\ @@ -15,6 +14,7 @@ ${doc(s, c)}\ #[derive(RustcEncodable, RustcDecodable, Default, Clone)] pub struct ${s.id}\ +% if s.type == 'object': % if 'properties' in s: { % for pn, p in s.properties.iteritems(): @@ -22,9 +22,12 @@ pub struct ${s.id}\ pub ${mangle_ident(pn)}: ${to_rust_type(s.id, pn, p)}, % endfor } -% else: +% else: ## it's an empty struct, i.e. struct Foo; ; -% endif +% endif ## 'properties' in s +% else: +(${to_rust_type(s.id, s.id, s)}); +% endif ## type == 'object' % for marker_trait in markers: impl ${marker_trait} for ${s.id} {} @@ -72,4 +75,9 @@ ${''.join("* [%s](struct.%s.html) (%s)\n" % (activity_split(a)[2], mb_type(*acti This type is not used in any activity, and only used as *part* of another schema. % endif +% if s.type != 'object': + +## for some reason, it's not shown in rustdoc ... +The contained type is `${to_rust_type(s.id, s.id, s)}`. +%endif \ No newline at end of file diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index 4b43007847..6dbf9273e0 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -339,9 +339,9 @@ def iter_nested_types(schemas): ns = deepcopy(p) ns.id = nested_type_name(prefix, pn) ns[NESTED_TYPE_MARKER] = True - if 'items' in p: - ns.update(p.items.iteritems()) + yield ns + for np in iter_nested_properties(prefix + canonical_type_name(pn), ns.properties): yield np elif _is_map_prop(p):