moonshine_util/
lib.rs

1#![doc = include_str!("../README.md")]
2#![warn(missing_docs)]
3
4pub mod component;
5pub mod defer;
6pub mod diagnostics;
7pub mod event;
8pub mod expect;
9pub mod hierarchy;
10pub mod query;
11pub mod reflect;
12pub mod spawn;
13pub mod system;
14
15pub mod prelude {
16    //! Prelude module to import the most essential utilities.
17
18    pub use crate::component::{Merge, MergeComponent, MergeFrom, MergeWith};
19    pub use crate::defer::{run_deferred_systems, RunDeferredSystem};
20    pub use crate::event::{AddSingleObserver, OnSingle, SingleEvent, TriggerSingle};
21    pub use crate::expect::Expect;
22    pub use crate::query::{Get, MapQuery};
23    pub use crate::reflect::Registerable;
24    pub use crate::spawn::{SpawnUnrelated, WithChild};
25    pub use crate::Static;
26
27    pub use crate::relationship;
28}
29
30/// Wrapper for [`disqualified::ShortName`] since it was removed from Bevy standard.
31///
32/// This avoids the need to add a dependency on [`disqualified`] if you're already using `moonshine` crates.
33pub fn get_short_name(name: &str) -> String {
34    disqualified::ShortName(name).to_string()
35}
36
37/// Convenient wrapper for [`get_short_name`] which infers the type name from the type parameter.
38pub fn get_short_type_name<T>() -> String {
39    get_short_name(std::any::type_name::<T>())
40}
41
42/// Convenient alias for `'static + Send + Sync` because recently I've started mumbling
43/// `'static + Send + Sync` in my sleep. My doctor has recommended I use this trait instead.
44///
45/// And so should you! It's clinically proven to reduce stress and wrist tension.
46pub trait Static: 'static + Send + Sync {}
47
48impl<T: 'static + Send + Sync> Static for T {}