Closed wcampbell0x2a closed 1 year ago
Actually not sure how to solve this. Looks like the impl<N: Nice>
is required at the beginning, but deku has no way of knowing that bound.
Nevermind, struct Test<N : Nice> {
fixes this.
This isn't an issue with deku, just noting you need to use PhantomData for this to work:
use std::marker::PhantomData;
use deku::prelude::*;
trait Nice {}
struct Kind<N: Nice> {
n: N,
endian: deku::ctx::Endian,
}
#[derive(DekuRead)]
#[deku(ctx = "kind: Kind<N>")]
#[deku(endian = "kind.endian ")]
struct Test<N: Nice> {
whatever: u8,
#[deku(skip)]
phantom: PhantomData<N>,
}
fn main() {
}
Otherwise you get this error!:
error[E0392]: parameter `N` is never used
--> src/main.rs:13:13
|
13 | struct Test<N: Nice> {
| ^ unused parameter
|
= help: consider removing `N`, referring to it in a field, or using a marker such as `PhantomData`
For more information about this error, try `rustc --explain E0392`.
error: could not compile `testing` due to previous error
This code with a struct generic type parameter
Generates this:
Should be this: