Is it supposed to work for u16?
Closed this issue · 1 comments
madprogrammer commented
Hello,
I'm getting a compilation error using u16
as the underlying type:
error[E0277]: the trait bound `u8: From<u16>` is not satisfied
--> bmapi-sys/src/dpcdecl.rs:298:1
|
298 | #[bitfield(u16)]
| ^^^^^^^^^^^^^^^^ the trait `From<u16>` is not implemented for `u8`
|
= help: the following other types implement trait `From<T>`:
<u8 as From<NonZeroU8>>
<u8 as From<bool>>
= note: required for `u16` to implement `Into<u8>`
= note: this error originates in the attribute macro `bitfield` (in Nightly builds, run with -Z macro-backtrace for more info)
The struct definition is:
#[bitfield(u16)]
pub struct BMDataHeader {
#[bits(4)]
pub kind: u8,
#[bits(4)]
pub flags: u8,
#[bits(4)]
pub dchn: u8,
#[bits(4)]
pub schn: u8
}
How can I fix it?
madprogrammer commented
Sorry, my mistake. The definition for field kind
was actualy a type Foo = u8
, after changing it to plain u8
the error is gone.