1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use super::{Func, Global, Memory, Table};
#[derive(Debug, Copy, Clone)]
pub enum Extern {
Global(Global),
Table(Table),
Memory(Memory),
Func(Func),
}
impl From<Global> for Extern {
fn from(global: Global) -> Self {
Self::Global(global)
}
}
impl From<Table> for Extern {
fn from(table: Table) -> Self {
Self::Table(table)
}
}
impl From<Memory> for Extern {
fn from(memory: Memory) -> Self {
Self::Memory(memory)
}
}
impl From<Func> for Extern {
fn from(func: Func) -> Self {
Self::Func(func)
}
}
impl Extern {
pub fn into_global(self) -> Option<Global> {
if let Self::Global(global) = self {
return Some(global);
}
None
}
pub fn into_table(self) -> Option<Table> {
if let Self::Table(table) = self {
return Some(table);
}
None
}
pub fn into_memory(self) -> Option<Memory> {
if let Self::Memory(memory) = self {
return Some(memory);
}
None
}
pub fn into_func(self) -> Option<Func> {
if let Self::Func(func) = self {
return Some(func);
}
None
}
}