diff --git a/gen/youtube3/src/lib.rs b/gen/youtube3/src/lib.rs index da3c5734f6..0dec81ea29 100644 --- a/gen/youtube3/src/lib.rs +++ b/gen/youtube3/src/lib.rs @@ -120,11 +120,11 @@ //! #![feature(core,io)] // DEBUG !! TODO: Remove this -#![allow(dead_code, unused_mut)] +#![allow(dead_code)] // We don't warn about this, as depending on the API, some data structures or facilities are never used. // Instead of pre-determining this, we just disable the lint. It's manually tuned to not have any -// unused imports in fully featured APIs -#![allow(unused_imports)] +// unused imports in fully featured APIs. Same with unused_mut ... . +#![allow(unused_imports, unused_mut)] extern crate hyper; @@ -1281,7 +1281,7 @@ impl Part for ChannelSectionSnippet {} #[derive(RustcEncodable, RustcDecodable, Default, Clone)] pub struct ChannelContentDetails { /// no description provided - pub related_playlists: ChannelContentDetailsRelatedPlaylists, + pub related_playlists: Option, /// The googlePlusUserId object identifies the Google+ profile ID associated with this channel. pub google_plus_user_id: Option, } diff --git a/src/mako/lib/util.py b/src/mako/lib/util.py index bb9527ad6b..4b43007847 100644 --- a/src/mako/lib/util.py +++ b/src/mako/lib/util.py @@ -279,31 +279,28 @@ def to_rust_type(sn, pn, t, allow_optionals=True): return nested_type_name(sn, pn) return to_rust_type(sn, pn, nt, allow_optionals=False) + def wrap_type(tn): + if allow_optionals: + tn = "Option<%s>" % tn + return tn + # unconditionally handle $ref types, which should point to another schema. if TREF in t: - tn = t[TREF] - if allow_optionals: - return "Option<%s>" % tn - return tn + return wrap_type(t[TREF]) 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 + return "%s<%s>" % (rust_type, nested_type(t)) elif t.type == 'object': if _is_map_prop(t): - rust_type = "%s" % (rust_type, nested_type(t)) + return "%s" % (rust_type, nested_type(t)) else: - rust_type = nested_type(t) - is_pod = False + return wrap_type(nested_type(t)) elif t.type == 'string' and 'Count' in pn: rust_type = 'i64' 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 + return wrap_type(rust_type) except KeyError as err: raise AssertionError("%s: Property type '%s' unknown - add new type mapping: %s" % (str(err), t.type, str(t))) except AttributeError as err: