Re: [PATCH v2 1/3] rust: core abstractions for network PHY drivers

Trevor Gross
2023-10-08T06:19:59Z

On Sat, Oct 7, 2023 at 6:33 PM FUJITA Tomonori
<fujita.tomonori@gmail.com> wrote:
> To create an internal type based on `name`, we need to unstringify
> `name`? I can't find a easy way to do it.

I think you should just be able to do it with `paste!`

macro_rules! module_phy_driver {
(name: $name:expr) => {
paste::paste! {
#[allow(non_camel_case_types)]
struct [<$name _ty>];
}
}
}

// creates struct `demo_driver_ty`
module_phy_driver! {
name: "demo_driver"
}