tangled
alpha
login
or
join now
buttplug.io
/
buttplug
20
fork
atom
Buttplug sex toy control library
20
fork
atom
overview
issues
pulls
pipelines
chore: Fix buttplug_derive for 2024 edition gen
qdot.tngl.sh
8 months ago
f20475c1
d0927762
+18
-18
1 changed file
expand all
collapse all
unified
split
crates
buttplug_derive
src
lib.rs
+18
-18
crates/buttplug_derive/src/lib.rs
···
27
27
syn::Data::Enum(ref e) => {
28
28
let idents = e.variants.iter().map(|x| x.ident.clone());
29
29
let idents2 = idents.clone();
30
30
-
let gen = quote! {
30
30
+
let r#gen = quote! {
31
31
impl ButtplugMessage for #name {
32
32
fn id(&self) -> u32 {
33
33
match self {
···
42
42
}
43
43
}
44
44
};
45
45
-
gen.into()
45
45
+
r#gen.into()
46
46
}
47
47
syn::Data::Struct(_) => {
48
48
-
let gen = quote! {
48
48
+
let r#gen = quote! {
49
49
impl ButtplugMessage for #name {
50
50
fn id(&self) -> u32 {
51
51
self.id
···
56
56
}
57
57
}
58
58
};
59
59
-
gen.into()
59
59
+
r#gen.into()
60
60
}
61
61
_ => panic!("Derivation only works on structs and enums"),
62
62
}
···
78
78
match ast.data {
79
79
syn::Data::Enum(ref e) => {
80
80
let idents: Vec<_> = e.variants.iter().map(|x| x.ident.clone()).collect();
81
81
-
let gen = quote! {
81
81
+
let r#gen = quote! {
82
82
impl ButtplugDeviceMessage for #name {
83
83
fn device_index(&self) -> u32 {
84
84
match self {
···
93
93
}
94
94
}
95
95
};
96
96
-
gen.into()
96
96
+
r#gen.into()
97
97
}
98
98
syn::Data::Struct(_) => {
99
99
-
let gen = quote! {
99
99
+
let r#gen = quote! {
100
100
impl ButtplugDeviceMessage for #name {
101
101
fn device_index(&self) -> u32 {
102
102
self.device_index
···
107
107
}
108
108
}
109
109
};
110
110
-
gen.into()
110
110
+
r#gen.into()
111
111
}
112
112
_ => panic!("Derivation only works on structs and enums"),
113
113
}
···
129
129
match &ast.data {
130
130
syn::Data::Enum(e) => {
131
131
let idents: Vec<_> = e.variants.iter().map(|x| x.ident.clone()).collect();
132
132
-
let gen = quote! {
132
132
+
let r#gen = quote! {
133
133
impl ButtplugMessageValidator for #name {
134
134
fn is_valid(&self) -> Result<(), ButtplugMessageError> {
135
135
match self {
···
138
138
}
139
139
}
140
140
};
141
141
-
gen.into()
141
141
+
r#gen.into()
142
142
}
143
143
syn::Data::Struct(_) => {
144
144
-
let gen = quote! {
144
144
+
let r#gen = quote! {
145
145
impl ButtplugMessageValidator for #name {
146
146
}
147
147
};
148
148
-
gen.into()
148
148
+
r#gen.into()
149
149
}
150
150
_ => panic!("Derivation only works on structs and enums"),
151
151
}
···
166
166
167
167
match &ast.data {
168
168
syn::Data::Enum(_) => {
169
169
-
let gen = quote! {
169
169
+
let r#gen = quote! {
170
170
impl ButtplugMessageFinalizer for #name {}
171
171
};
172
172
-
gen.into()
172
172
+
r#gen.into()
173
173
}
174
174
syn::Data::Struct(_) => {
175
175
-
let gen = quote! {
175
175
+
let r#gen = quote! {
176
176
impl ButtplugMessageFinalizer for #name {}
177
177
};
178
178
-
gen.into()
178
178
+
r#gen.into()
179
179
}
180
180
_ => panic!("Derivation only works on structs and enums"),
181
181
}
···
205
205
fields.push(field.ty.clone());
206
206
}
207
207
}
208
208
-
let gen = quote! {
208
208
+
let r#gen = quote! {
209
209
#(impl From<#fields> for #name {
210
210
fn from(msg: #fields) -> #name {
211
211
#name::#idents(msg)
212
212
}
213
213
})*
214
214
};
215
215
-
gen.into()
215
215
+
r#gen.into()
216
216
} else {
217
217
panic!("FromButtplugMessageUnion only works on structs");
218
218
}