bytecodealliance / bytecodealliance/wasm-tools
How to compare Operator and Type, these type not implement eq
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 351
- Avg merge
- 16h 57m
- Merged PRs (30d)
- 38
Description
i want to assert Operator and Type but failed
```rs
assert_eq!(
get_function_body(&edit_raw_wasm, 0).as_slice(),
&vec![I32Const{value:2}, Call{function_index:1}, GlobalGet{global_index:1}, Call{function_index:2}, End][..]
);
```
```rs
pub fn resolve_type_idx(&self, t: &Type) ->Option {
for (index, ty) in self.types_map.iter().enumerate() {
if matches!(t, ty) {
return Some(index as u32);
}
}
return None;
}
```
type defined like this
```rs
#[derive(Debug, Clone)]
pub enum Type {
/// The type is for a function.
Func(FuncType),
}
#[derive(Clone)]
pub struct BrTable<'a> {
pub(crate) reader: crate::BinaryReader<'a>,
pub(crate) cnt: u32,
pub(crate) default: u32,
}
#[derive(Debug, Clone)]
pub enum Type {
/// The type is for a function.
Func(FuncType),
}
#[derive(Clone)]
pub struct BrTable<'a> {
pub(crate) reader: crate::BinaryReader<'a>,
pub(crate) cnt: u32,
pub(crate) default: u32,
}
macro_rules! define_operator {
($(@$proposal:ident $op:ident $({ $($payload:tt)* })? => $visit:ident)*) => {
/// Instructions as defined [here].
///
/// [here]: https://webassembly.github.io/spec/core/binary/instructions.html
#[derive(Debug, Clone)]
#[allow(missing_docs)]
pub enum Operator<'a> {
$(
$op $({ $($payload)* })?,
)*
}
}
}
macro_rules! define_operator {
($(@$proposal:ident $op:ident $({ $($payload:tt)* })? => $visit:ident)*) => {
/// Instructions as defined [here].
///
/// [here]: https://webassembly.github.io/spec/core/binary/instructions.html
#[derive(Debug, Clone)]
#[allow(missing_docs)]
pub enum Operator<'a> {
$(
$op $({ $($payload)* })?,
)*
}
}
}
```
could make this enum can be equal
Contributor guide
Assessment
This issue has not been assessed yet.