From dab378931c86042f00502d52a155b85f1bd12797 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 6 Oct 2022 17:22:55 -0700 Subject: [PATCH 1/2] wasmtime-component-macro: struct and consts created for flags! must be pub --- crates/component-macro/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/component-macro/src/lib.rs b/crates/component-macro/src/lib.rs index 77b9aa9934ca..d16918ffde39 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,7 +1128,7 @@ fn expand_flags(flags: &Flags) -> Result { let expanded = quote! { #[derive(Copy, Clone, Default)] - struct #name { #fields } + pub struct #name { #fields } impl #name { #constants From 4762cddb2e970088a4a754063cc9918b3f2606cd Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Fri, 7 Oct 2022 13:49:05 -0700 Subject: [PATCH 2/2] addd empty and all constructors to flags --- crates/component-macro/src/lib.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/component-macro/src/lib.rs b/crates/component-macro/src/lib.rs index d16918ffde39..0524ef2600ac 100644 --- a/crates/component-macro/src/lib.rs +++ b/crates/component-macro/src/lib.rs @@ -1133,9 +1133,18 @@ fn expand_flags(flags: &Flags) -> Result { 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 {