/// Generate a manual implementation of `PartialEq` trait for the /// specified compound type. pub(crate) fn gen_partialeq_impl(
ctx: &BindgenContext,
comp_info: &CompInfo,
item: &Item,
ty_for_impl: &proc_macro2::TokenStream,
) -> Option<proc_macro2::TokenStream> { letmut tokens = vec![];
if item.is_opaque(ctx, &()) {
tokens.push(quote! {
&self._bindgen_opaque_blob[..] == &other._bindgen_opaque_blob[..]
});
} elseif comp_info.kind() == CompKind::Union {
assert!(!ctx.options().untagged_union);
tokens.push(quote! {
&self.bindgen_union_field[..] == &other.bindgen_union_field[..]
});
} else { for base in comp_info.base_members() { if !base.requires_storage(ctx) { continue;
}
let ty_item = ctx.resolve_item(base.ty); let field_name = &base.field_name;
tokens.push(gen_field(ctx, ty_item, field_name));
}
for field in comp_info.fields() { match *field {
Field::DataMember(ref fd) => { let ty_item = ctx.resolve_item(fd.ty()); let name = fd.name().unwrap();
tokens.push(gen_field(ctx, ty_item, name));
}
Field::Bitfields(ref bu) => { for bitfield in bu.bitfields() { if bitfield.name().is_some() { let getter_name = bitfield.getter_name(); let name_ident = ctx.rust_ident_raw(getter_name);
tokens.push(quote! { self.#name_ident () == other.#name_ident ()
});
}
}
}
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.