bevy_scene/macro_utils.rs
1use bevy_platform::sync::atomic::AtomicU64;
2use bevy_platform::sync::atomic::Ordering;
3
4/// This is used by the [`bsn!`](crate::bsn) macro to generate compile-time only references to symbols. Currently this is used
5/// to add IDE support for nested type names, as it allows us to pass the input Ident from the input to the output code.
6pub const fn touch_type<T>() {}
7
8/// This is used by the [`bsn!`](crate::bsn) derive to work around [this Rust limitation](https://github.com/rust-lang/rust/issues/86935).
9/// A fix is implemented and on track for stabilization. If it is ever implemented, we can remove this.
10pub type PathResolveHelper<T> = T;
11
12/// A counter meant to be stored in a `static` to differentiate multiple evaluations of the expression returned by [`bsn!`](crate::bsn)
13///
14/// Required for named entity references
15pub struct CallCounter(AtomicU64);
16
17impl CallCounter {
18 /// Creates a new counter starting at 0
19 #[expect(
20 clippy::new_without_default,
21 reason = "Needs to be a associated const fn for use in static"
22 )]
23 pub const fn new() -> Self {
24 Self(AtomicU64::new(0))
25 }
26 /// Get the current count and then increment this counter by 1
27 pub fn increment(&self) -> u64 {
28 self.0.fetch_add(1, Ordering::Relaxed)
29 }
30}