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
diff --git a/tests/test.rs b/tests/test.rs
index e7e9eff..34ea048 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -4,7 +4,7 @@ mod small_prime {
use super::*;
#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)]
- #[repr(u8)]
+ #[repr(C)]
enum SmallPrime {
Two = 2,
Three = 3,
Compiling serde_repr v0.1.6 (/home/elmarco/src/serde-repr)
error[E0412]: cannot find type `C` in this scope
--> tests/test.rs:7:12
|
6 | #[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)]
| -------------- similarly named type parameter `S` defined here
7 | #[repr(C)]
| ^ help: a type parameter with a similar name exists: `S`
error[E0412]: cannot find type `C` in this scope
--> tests/test.rs:7:12
|
6 | #[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug)]
| ---------------- similarly named type parameter `D` defined here
7 | #[repr(C)]
| ^ help: a type parameter with a similar name exists: `D`
Is there a workaround or possible solution ? (is it possible to get the underlying chosen int?)
The text was updated successfully, but these errors were encountered:
This is not supported by this crate. The repr is required to be a specific integer type.
But cannot find type `C` in this scope is not a good error message. I'll make a PR to change that.
To support repr(C), you could look for, or create, an attribute macro that inspects a set of enum discriminants and expands to the same integer repr that would be chosen by a C compiler.
#[infer_C_repr]#[derive(Serialize_repr)]pubenumEnum{
...
}// expands to:#[repr(i16)]// for example#[derive(Serialize_repr)]pubenumEnum{
...
}
Hi
An enum with a repr(C) will fail to compile:
Is there a workaround or possible solution ? (is it possible to get the underlying chosen int?)
The text was updated successfully, but these errors were encountered: