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: impl/doc/try_from.md
+79-3Lines changed: 79 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -7,9 +7,17 @@ Derive `TryFrom` allows you to convert enum discriminants into their correspondi
7
7
8
8
## Enums
9
9
10
-
By default, a `TryFrom<isize>` is generated, matching the [type of the discriminant](https://doc.rust-lang.org/reference/items/enumerations.html#discriminants).
11
-
The type can be changed with a `#[repr(u/i*)]` attribute, e.g., `#[repr(u8)]` or `#[repr(i32)]`.
12
-
Only field-less variants can be constructed from their variant, therefore the `TryFrom` implementation will return an error for a discriminant representing a variant with fields.
10
+
Enums can be generated either from a `repr` discriminant value or a custom type.
11
+
12
+
### Repr
13
+
14
+
In the `repr` mode, by default, a `TryFrom<isize>` is generated, matching the
0 commit comments