Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: @glchapman Fixes #11 So the enum ```rust #[derive(TryFromPrimitive)] #[repr(u8)] enum Example { A, B, C, D, E, F = 8, G, H, I, J, K, L, M, } ``` now generates: ```rust impl ::num_enum::TryFromPrimitive for Example { // ... fn try_from_primitive(number: Self::Primitive) -> ::core::result::Result<Self, ::num_enum::TryFromPrimitiveError<Self>> { #![allow(non_upper_case_globals)] const A: u8 = 0; const B: u8 = u8::wrapping_add(A, 1); const C: u8 = u8::wrapping_add(B, 1); const D: u8 = u8::wrapping_add(C, 1); const E: u8 = u8::wrapping_add(D, 1); const F: u8 = 8; const G: u8 = u8::wrapping_add(F, 1); const H: u8 = u8::wrapping_add(G, 1); const I: u8 = u8::wrapping_add(H, 1); const J: u8 = u8::wrapping_add(I, 1); const K: u8 = u8::wrapping_add(J, 1); const L: u8 = u8::wrapping_add(K, 1); const M: u8 = u8::wrapping_add(L, 1); ```
- Loading branch information