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
This commit is contained in:
@@ -1081,7 +1081,7 @@ fn expand_flags(flags: &Flags) -> Result<TokenStream> {
|
|||||||
|
|
||||||
let name = format_ident!("{}", name);
|
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 {
|
let generics = syn::Generics {
|
||||||
@@ -1128,14 +1128,23 @@ fn expand_flags(flags: &Flags) -> Result<TokenStream> {
|
|||||||
|
|
||||||
let expanded = quote! {
|
let expanded = quote! {
|
||||||
#[derive(Copy, Clone, Default)]
|
#[derive(Copy, Clone, Default)]
|
||||||
struct #name { #fields }
|
pub struct #name { #fields }
|
||||||
|
|
||||||
impl #name {
|
impl #name {
|
||||||
#constants
|
#constants
|
||||||
|
|
||||||
fn as_array(&self) -> [u32; #count] {
|
pub fn as_array(&self) -> [u32; #count] {
|
||||||
#as_array
|
#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 {
|
impl std::cmp::PartialEq for #name {
|
||||||
|
|||||||
Reference in New Issue
Block a user