Skip to content

Commit 01c8935

Browse files
author
Michael Bryan
authored
Derive Clone and PartialEq for wit_parser::Interface (#304)
1 parent cb871cf commit 01c8935

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

crates/parser/src/lib.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn validate_id(s: &str) -> Result<()> {
1616
Ok(())
1717
}
1818

19-
#[derive(Debug, Default)]
19+
#[derive(Debug, Clone, Default, PartialEq)]
2020
pub struct Interface {
2121
pub name: String,
2222
/// The module name to use for bindings generation.
@@ -41,7 +41,7 @@ pub type TypeId = Id<TypeDef>;
4141
pub type ResourceId = Id<Resource>;
4242
pub type InterfaceId = Id<Interface>;
4343

44-
#[derive(Debug)]
44+
#[derive(Debug, Clone, PartialEq)]
4545
pub struct TypeDef {
4646
pub docs: Docs,
4747
pub kind: TypeDefKind,
@@ -51,7 +51,7 @@ pub struct TypeDef {
5151
pub foreign_module: Option<String>,
5252
}
5353

54-
#[derive(Debug)]
54+
#[derive(Debug, Clone, PartialEq)]
5555
pub enum TypeDefKind {
5656
Record(Record),
5757
Flags(Flags),
@@ -95,24 +95,24 @@ pub enum Int {
9595
U64,
9696
}
9797

98-
#[derive(Debug)]
98+
#[derive(Debug, Clone, PartialEq)]
9999
pub struct Record {
100100
pub fields: Vec<Field>,
101101
}
102102

103-
#[derive(Debug)]
103+
#[derive(Debug, Clone, PartialEq)]
104104
pub struct Field {
105105
pub docs: Docs,
106106
pub name: String,
107107
pub ty: Type,
108108
}
109109

110-
#[derive(Debug, Clone)]
110+
#[derive(Debug, Clone, PartialEq)]
111111
pub struct Flags {
112112
pub flags: Vec<Flag>,
113113
}
114114

115-
#[derive(Debug, Clone)]
115+
#[derive(Debug, Clone, PartialEq)]
116116
pub struct Flag {
117117
pub docs: Docs,
118118
pub name: String,
@@ -145,17 +145,17 @@ impl FlagsRepr {
145145
}
146146
}
147147

148-
#[derive(Debug, Clone)]
148+
#[derive(Debug, Clone, PartialEq)]
149149
pub struct Tuple {
150150
pub types: Vec<Type>,
151151
}
152152

153-
#[derive(Debug)]
153+
#[derive(Debug, Clone, PartialEq)]
154154
pub struct Variant {
155155
pub cases: Vec<Case>,
156156
}
157157

158-
#[derive(Debug)]
158+
#[derive(Debug, Clone, PartialEq)]
159159
pub struct Case {
160160
pub docs: Docs,
161161
pub name: String,
@@ -173,12 +173,12 @@ impl Variant {
173173
}
174174
}
175175

176-
#[derive(Debug)]
176+
#[derive(Debug, Clone, PartialEq)]
177177
pub struct Enum {
178178
pub cases: Vec<EnumCase>,
179179
}
180180

181-
#[derive(Debug, Clone)]
181+
#[derive(Debug, Clone, PartialEq)]
182182
pub struct EnumCase {
183183
pub docs: Docs,
184184
pub name: String,
@@ -195,18 +195,18 @@ impl Enum {
195195
}
196196
}
197197

198-
#[derive(Debug)]
198+
#[derive(Debug, Clone, PartialEq)]
199199
pub struct Expected {
200200
pub ok: Type,
201201
pub err: Type,
202202
}
203203

204-
#[derive(Debug)]
204+
#[derive(Debug, Clone, PartialEq)]
205205
pub struct Union {
206206
pub cases: Vec<UnionCase>,
207207
}
208208

209-
#[derive(Debug, Clone)]
209+
#[derive(Debug, Clone, PartialEq)]
210210
pub struct UnionCase {
211211
pub docs: Docs,
212212
pub ty: Type,
@@ -223,18 +223,18 @@ impl Union {
223223
}
224224
}
225225

226-
#[derive(Debug)]
226+
#[derive(Debug, Clone, PartialEq)]
227227
pub struct Stream {
228228
pub element: Type,
229229
pub end: Type,
230230
}
231231

232-
#[derive(Clone, Default, Debug)]
232+
#[derive(Clone, Default, Debug, PartialEq)]
233233
pub struct Docs {
234234
pub contents: Option<String>,
235235
}
236236

237-
#[derive(Debug)]
237+
#[derive(Debug, Clone, PartialEq)]
238238
pub struct Resource {
239239
pub docs: Docs,
240240
pub name: String,
@@ -244,14 +244,14 @@ pub struct Resource {
244244
pub foreign_module: Option<String>,
245245
}
246246

247-
#[derive(Debug)]
247+
#[derive(Debug, Clone, PartialEq)]
248248
pub struct Global {
249249
pub docs: Docs,
250250
pub name: String,
251251
pub ty: Type,
252252
}
253253

254-
#[derive(Debug)]
254+
#[derive(Debug, Clone, PartialEq)]
255255
pub struct Function {
256256
pub is_async: bool,
257257
pub docs: Docs,
@@ -261,7 +261,7 @@ pub struct Function {
261261
pub result: Type,
262262
}
263263

264-
#[derive(Debug)]
264+
#[derive(Debug, Clone, PartialEq)]
265265
pub enum FunctionKind {
266266
Freestanding,
267267
Static { resource: ResourceId, name: String },

0 commit comments

Comments
 (0)