22//!
33//! The focal point of this module is the [`LanguageExtension`] API.
44
5- /// A language extension not guaranteed to be present in all environments.
5+ use strum:: VariantArray ;
6+
7+ /// A language extension recognized by Naga, but not guaranteed to be present in all environments.
68///
79/// WGSL spec.: <https://www.w3.org/TR/WGSL/#language-extensions-sec>
810#[ derive( Clone , Copy , Debug , Eq , Hash , PartialEq ) ]
9- pub ( crate ) enum LanguageExtension {
11+ pub enum LanguageExtension {
1012 #[ allow( unused) ]
1113 Implemented ( ImplementedLanguageExtension ) ,
1214 Unimplemented ( UnimplementedLanguageExtension ) ,
@@ -41,7 +43,7 @@ impl LanguageExtension {
4143 /// Maps this [`LanguageExtension`] into the sentinel word associated with it in WGSL.
4244 pub const fn to_ident ( self ) -> & ' static str {
4345 match self {
44- Self :: Implemented ( kind) => match kind { } ,
46+ Self :: Implemented ( kind) => kind. to_ident ( ) ,
4547 Self :: Unimplemented ( kind) => match kind {
4648 UnimplementedLanguageExtension :: ReadOnlyAndReadWriteStorageTextures => {
4749 Self :: READONLY_AND_READWRITE_STORAGE_TEXTURES
@@ -61,12 +63,24 @@ impl LanguageExtension {
6163}
6264
6365/// A variant of [`LanguageExtension::Implemented`].
64- #[ derive( Clone , Copy , Debug , Eq , Hash , PartialEq ) ]
65- pub ( crate ) enum ImplementedLanguageExtension { }
66+ #[ derive( Clone , Copy , Debug , Eq , Hash , PartialEq , VariantArray ) ]
67+ pub enum ImplementedLanguageExtension { }
68+
69+ impl ImplementedLanguageExtension {
70+ /// Returns slice of all variants of [`ImplementedLanguageExtension`].
71+ pub const fn all ( ) -> & ' static [ Self ] {
72+ Self :: VARIANTS
73+ }
74+
75+ /// Maps this [`ImplementedLanguageExtension`] into the sentinel word associated with it in WGSL.
76+ pub const fn to_ident ( self ) -> & ' static str {
77+ match self { }
78+ }
79+ }
6680
6781/// A variant of [`LanguageExtension::Unimplemented`].
6882#[ derive( Clone , Copy , Debug , Eq , Hash , PartialEq ) ]
69- pub ( crate ) enum UnimplementedLanguageExtension {
83+ pub enum UnimplementedLanguageExtension {
7084 ReadOnlyAndReadWriteStorageTextures ,
7185 Packed4x8IntegerDotProduct ,
7286 UnrestrictedPointerParameters ,
0 commit comments