From 42d460f3a67ef5fdcf072d30a7751c1bd975272e Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Fri, 7 Oct 2022 16:36:27 -0700 Subject: [PATCH] wasmtime-component-macro: struct and consts created for flags! must be pub (#5030) * wasmtime-component-macro: struct and consts created for flags! must be pub * addd empty and all constructors to flags --- crates/component-macro/src/lib.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/component-macro/src/lib.rs b/crates/component-macro/src/lib.rs index 77b9aa9934..0524ef2600 100644 --- a/crates/component-macro/src/lib.rs +++ b/crates/component-macro/src/lib.rs @@ -1081,7 +1081,7 @@ fn expand_flags(flags: &Flags) -> Result { let name = format_ident!("{}", name); - constants.extend(quote!(const #name: Self = Self { #fields };)); + constants.extend(quote!(pub const #name: Self = Self { #fields };)); } let generics = syn::Generics { @@ -1128,14 +1128,23 @@ fn expand_flags(flags: &Flags) -> Result { let expanded = quote! { #[derive(Copy, Clone, Default)] - struct #name { #fields } + pub struct #name { #fields } impl #name { #constants - fn as_array(&self) -> [u32; #count] { + pub fn as_array(&self) -> [u32; #count] { #as_array } + + pub fn empty() -> Self { + Self::default() + } + + pub fn all() -> Self { + use std::ops::Not; + Self::default().not() + } } impl std::cmp::PartialEq for #name {