You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/lib.rs
+42-20
Original file line number
Diff line number
Diff line change
@@ -160,6 +160,48 @@ impl Parse for EnumConversionsArgs {
160
160
}
161
161
}
162
162
163
+
/// Derive macro that generates conversions between an enum and its variants and other types.
164
+
///
165
+
/// The macro can be used as follows:
166
+
///
167
+
/// ```rust
168
+
/// use nested_enum_utils::enum_conversions;
169
+
///
170
+
/// #[enum_conversions()]
171
+
/// enum MyEnum {
172
+
/// Variant1(u32),
173
+
/// Variant2(String),
174
+
/// }
175
+
/// ```
176
+
///
177
+
/// This will create From instances from each variant type to the enum and TryFrom instances from the enum to each variant type.
178
+
///
179
+
/// The macro also accepts a list of target types to generate conversions to:
180
+
///
181
+
/// ```rust
182
+
/// use nested_enum_utils::enum_conversions;
183
+
///
184
+
/// #[enum_conversions(Outer)]
185
+
/// enum Inner {
186
+
/// Variant1(u32),
187
+
/// Variant2(String),
188
+
/// }
189
+
///
190
+
/// #[enum_conversions()]
191
+
/// enum Outer {
192
+
/// Inner1(Inner),
193
+
/// // other variants
194
+
/// }
195
+
/// ```
196
+
///
197
+
/// This will, in addition, generate From instances from each variant type to the outer enum and TryFrom instances from the outer enum to each variant type.
198
+
/// The conversion to the outer enum relies on conversions between the inner enum and the outer enum, which is provided by the
0 commit comments