Const Abc: Enum

pub enum Foo {

pub struct X_Texture<const Width: u32, const Height: u32, const Layers: u32, const Format: Foo> {
    inner: wgpu::Texture,

This code right now does not work since Foo is not a integers, bool, or char

For an enum T <-> u8, is there a way to use T as a generic constant ?

It's a bit janky with an enum, but here we are:

enum Foo {

struct Bar<const N: u8>;

fn main(){ 
    let this = Bar::<{Foo::A as u8}>;

It also looks like you are trying to use a Typestate pattern, consider this:

use core::marker::PhantomData;

trait Foo {}
impl Foo for A {}
impl Foo for B {}

struct A;
struct B;

struct Bar<T: Foo> {
    _phantom: PhantomData<T>,

fn main() {
    let this = Bar {
        _phantom: PhantomData::<A>

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.