@@ -115,6 +115,18 @@ pub fn make_enum_definition_with(
115115 let index_enum_impl = make_enum_index_impl ( enum_) ;
116116 let bitwise_impls = make_enum_bitwise_operators ( enum_, enum_bitmask. as_ref ( ) ) ;
117117
118+ let special_default_impl = if let Some ( override_default) = enum_. override_default . as_ref ( ) {
119+ quote ! {
120+ impl Default for #name {
121+ fn default ( ) -> Self {
122+ #override_default
123+ }
124+ }
125+ }
126+ } else {
127+ TokenStream :: new ( )
128+ } ;
129+
118130 let var_trait_set = if enum_. is_exhaustive {
119131 quote ! {
120132 fn var_set( field: & mut Self , value: Self :: Via ) {
@@ -144,6 +156,7 @@ pub fn make_enum_definition_with(
144156 #engine_trait_impl
145157 #index_enum_impl
146158 #bitwise_impls
159+ #special_default_impl
147160
148161 impl crate :: meta:: GodotConvert for #name {
149162 type Via = #ord_type;
@@ -485,7 +498,12 @@ fn make_enum_as_str(enum_: &Enum) -> TokenStream {
485498
486499/// Creates implementations for bitwise operators for the given enum.
487500///
488- /// Currently, this is just [`BitOr`](std::ops::BitOr) for bitfields but that could be expanded in the future.
501+ /// Currently, for bitfields this is the following (but could be expanded in the future):
502+ /// - [`BitOr`](std::ops::BitOr)
503+ /// - [`BitOrAssign`](std::ops::BitOrAssign)
504+ /// - [`BitAnd`](std::ops::BitAnd)
505+ /// - [`BitAndAssign`](std::ops::BitAndAssign)
506+ /// - [`Not`](std::ops::Not) (there is not a separate 'BitNot' trait)
489507fn make_enum_bitwise_operators ( enum_ : & Enum , enum_bitmask : Option < & RustTy > ) -> TokenStream {
490508 let name = & enum_. name ;
491509
@@ -507,6 +525,31 @@ fn make_enum_bitwise_operators(enum_: &Enum, enum_bitmask: Option<&RustTy>) -> T
507525 * self = * self | rhs;
508526 }
509527 }
528+
529+ impl std:: ops:: BitAnd for #name {
530+ type Output = Self ;
531+
532+ #[ inline]
533+ fn bitand( self , rhs: Self ) -> Self :: Output {
534+ Self { ord: self . ord & rhs. ord }
535+ }
536+ }
537+
538+ impl std:: ops:: BitAndAssign for #name {
539+ #[ inline]
540+ fn bitand_assign( & mut self , rhs: Self ) {
541+ * self = * self & rhs;
542+ }
543+ }
544+
545+ impl std:: ops:: Not for #name {
546+ type Output = Self ;
547+
548+ #[ inline]
549+ fn not( self ) -> Self :: Output {
550+ Self { ord: !self . ord }
551+ }
552+ }
510553 }
511554 } else if let Some ( mask_enum) = enum_bitmask {
512555 // Enum that has an accompanying bitfield for masking.
0 commit comments