mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-14 05:21:24 +00:00
Generate bindings for indexed struct properties
This allows to export fields of tuple-like structs as indexed JS properties.
This commit is contained in:
@ -227,7 +227,7 @@ pub struct Struct {
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
#[derive(Clone)]
|
||||
pub struct StructField {
|
||||
pub name: Ident,
|
||||
pub name: syn::Member,
|
||||
pub struct_name: Ident,
|
||||
pub readonly: bool,
|
||||
pub ty: syn::Type,
|
||||
|
@ -332,7 +332,10 @@ fn shared_struct<'a>(s: &'a ast::Struct, intern: &'a Interner) -> Struct<'a> {
|
||||
|
||||
fn shared_struct_field<'a>(s: &'a ast::StructField, intern: &'a Interner) -> StructField<'a> {
|
||||
StructField {
|
||||
name: intern.intern(&s.name),
|
||||
name: match &s.name {
|
||||
syn::Member::Named(ident) => intern.intern(ident),
|
||||
syn::Member::Unnamed(index) => intern.intern_str(&index.index.to_string()),
|
||||
},
|
||||
readonly: s.readonly,
|
||||
comments: s.comments.iter().map(|s| &**s).collect(),
|
||||
}
|
||||
|
Reference in New Issue
Block a user