mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-28 04:01:33 +00:00
Support Option
with custom enums in JS
Find a hole automatically to use a sentinel value for `None`, and then just wire everything up! Closes #1198
This commit is contained in:
@ -59,7 +59,7 @@ pub enum Descriptor {
|
||||
Vector(Box<Descriptor>),
|
||||
String,
|
||||
Anyref,
|
||||
Enum,
|
||||
Enum { hole: u32 },
|
||||
RustStruct(String),
|
||||
Char,
|
||||
Option(Box<Descriptor>),
|
||||
@ -128,7 +128,7 @@ impl Descriptor {
|
||||
OPTIONAL => Descriptor::Option(Box::new(Descriptor::_decode(data))),
|
||||
STRING => Descriptor::String,
|
||||
ANYREF => Descriptor::Anyref,
|
||||
ENUM => Descriptor::Enum,
|
||||
ENUM => Descriptor::Enum { hole: get(data) },
|
||||
RUST_STRUCT => {
|
||||
let name = (0..get(data))
|
||||
.map(|_| char::from_u32(get(data)).unwrap())
|
||||
@ -159,7 +159,7 @@ impl Descriptor {
|
||||
| Descriptor::U32
|
||||
| Descriptor::F32
|
||||
| Descriptor::F64
|
||||
| Descriptor::Enum => true,
|
||||
| Descriptor::Enum { .. } => true,
|
||||
_ => return false,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user