Skip to content

Commit 18d5707

Browse files
authored
Merge pull request #1097 from godot-rust/feature/bitor-assign
Bitfields now have `|=` operator
2 parents b7ea495 + 9f529e8 commit 18d5707

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

godot-codegen/src/generator/enums.rs

+7
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,13 @@ fn make_enum_bitwise_operators(enum_: &Enum) -> TokenStream {
372372
Self { ord: self.ord | rhs.ord }
373373
}
374374
}
375+
376+
impl std::ops::BitOrAssign for #name {
377+
#[inline]
378+
fn bitor_assign(&mut self, rhs: Self) {
379+
*self = *self | rhs;
380+
}
381+
}
375382
}
376383
} else if let Some(mask_enum) = special_cases::as_enum_bitmaskable(enum_) {
377384
// Enum that has an accompanying bitfield for masking.

itest/rust/src/builtin_tests/containers/callable_test.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,11 @@ pub mod custom_callable {
584584
assert_eq!(hash_count(&at), 1, "hash for a untouched if b is inserted");
585585
assert_eq!(hash_count(&bt), 1, "hash needed for b dict key");
586586

587-
// Introduced in https://github.com/godotengine/godot/pull/96797.
588-
let eq = if GdextBuild::since_api("4.4") { 2 } else { 1 };
587+
let eq = match GdextBuild::godot_runtime_version_triple() {
588+
(4, 1..=3, _) => 1,
589+
(4, 4, 0) => 2, // changed in https://github.com/godotengine/godot/pull/96797.
590+
_ => 1, // changed in https://github.com/godotengine/godot/pull/103647.
591+
};
589592

590593
assert_eq!(eq_count(&at), eq, "hash collision, eq for a needed");
591594
assert_eq!(eq_count(&bt), eq, "hash collision, eq for b needed");

0 commit comments

Comments
 (0)