@@ -279,31 +279,28 @@ def nested_type(nt):
279279 return nested_type_name (sn , pn )
280280 return to_rust_type (sn , pn , nt , allow_optionals = False )
281281
282- # unconditionally handle $ref types, which should point to another schema.
283- if TREF in t :
284- tn = t [TREF ]
282+ def wrap_type (tn ):
285283 if allow_optionals :
286- return "Option<%s>" % tn
284+ tn = "Option<%s>" % tn
287285 return tn
286+
287+ # unconditionally handle $ref types, which should point to another schema.
288+ if TREF in t :
289+ return wrap_type (t [TREF ])
288290 try :
289- is_pod = True
290291 rust_type = TYPE_MAP [t .type ]
291292 if t .type == 'array' :
292- rust_type = "%s<%s>" % (rust_type , nested_type (t ))
293- is_pod = False
293+ return "%s<%s>" % (rust_type , nested_type (t ))
294294 elif t .type == 'object' :
295295 if _is_map_prop (t ):
296- rust_type = "%s<String, %s>" % (rust_type , nested_type (t ))
296+ return "%s<String, %s>" % (rust_type , nested_type (t ))
297297 else :
298- rust_type = nested_type (t )
299- is_pod = False
298+ return wrap_type (nested_type (t ))
300299 elif t .type == 'string' and 'Count' in pn :
301300 rust_type = 'i64'
302301 elif rust_type == USE_FORMAT :
303302 rust_type = TYPE_MAP [t .format ]
304- if is_pod and allow_optionals :
305- return "Option<%s>" % rust_type
306- return rust_type
303+ return wrap_type (rust_type )
307304 except KeyError as err :
308305 raise AssertionError ("%s: Property type '%s' unknown - add new type mapping: %s" % (str (err ), t .type , str (t )))
309306 except AttributeError as err :
0 commit comments